Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeouts - change default timeout in fetcher from 30s to 2min #454

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import {
} from './tf-types'
import jsonldParser from './jsonldparser'

const DEFAULT_TIMEOUT_MS = 120000 // 2 mins

const Parsable = {
'text/n3': true,
'text/turtle': true,
Expand Down Expand Up @@ -185,7 +187,7 @@ export interface AutoInitOptions extends RequestInit{
original: NamedNode
// Like requeststatus? Can contain text with error.
data?: string
// Probably an identifier for request?s
// The request in the RDF metadata in the store
req: BlankNode
// Might be the same as Options.data
body?: string
Expand Down Expand Up @@ -750,7 +752,7 @@ export default class Fetcher implements CallbackifyInterface {
constructor (store: IndexedFormula, options: Options = {}) {
this.store = store || new IndexedFormula()
this.ns = getNS(this.store.rdfFactory)
this.timeout = options.timeout || 30000
this.timeout = options.timeout || DEFAULT_TIMEOUT_MS

this._fetch = options.fetch
|| (typeof global !== 'undefined' && global.solidFetcher)
Expand Down Expand Up @@ -818,7 +820,7 @@ export default class Fetcher implements CallbackifyInterface {
return requestedURI
}

static proxyIfNecessary (uri: string) {
static mapForLocalTesting:string (uri: string) {
var UI
if (
typeof window !== 'undefined' &&
Expand Down Expand Up @@ -853,6 +855,7 @@ export default class Fetcher implements CallbackifyInterface {
if (y) {
return y
}
return uri
}

// browser does 2014 on as https browser script not trusted
Expand Down Expand Up @@ -1049,7 +1052,7 @@ export default class Fetcher implements CallbackifyInterface {

Fetcher.setCredentials(requestedURI, options)

let actualProxyURI = Fetcher.proxyIfNecessary(requestedURI)
let actualProxyURI = Fetcher.mapForLocalTesting(requestedURI)
if (requestedURI !== actualProxyURI) {
options.proxyUsed = true
}
Expand Down Expand Up @@ -1560,8 +1563,9 @@ export default class Fetcher implements CallbackifyInterface {
}
Fetcher.setCredentials(uri, options)

const mappedURI = mapForLocalTesting(uri)
return new Promise(function (resolve, reject) {
fetcher._fetch(uri, options).then(response => {
fetcher._fetch(mappedURI, options).then(response => {
if (response.ok) {
if (method === 'PUT' || method === 'PATCH' || method === 'POST' || method === 'DELETE') {
fetcher.invalidateCache (uri)
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
},
"include": [
"src/**/*"
]
],
"moduleResolution": "node"
}