From 0ec87ab24238732d306e18b04d919f4347378938 Mon Sep 17 00:00:00 2001 From: Tim Berners-Lee Date: Fri, 6 Nov 2020 11:58:05 +0000 Subject: [PATCH 1/2] change default fetcher timeout from 30s to 2min --- src/fetcher.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fetcher.ts b/src/fetcher.ts index 25c344aef..1c0352e9c 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -55,6 +55,8 @@ import { Quad_Subject } from './tf-types' +const DEFAULT_TIMEOUT_MS = 120000 // 2 mins + const Parsable = { 'text/n3': true, 'text/turtle': true, @@ -718,7 +720,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 || this.defaultFetch() From 38cc49b18eb60ada46e72c67eca4612511945783 Mon Sep 17 00:00:00 2001 From: Tim Berners-Lee Date: Thu, 15 Apr 2021 11:21:00 -0400 Subject: [PATCH 2/2] Add URI mapping for testing to WebOperation just like load(). Also moduleResolution: node in tsconfig --- src/fetcher.ts | 10 ++++++---- tsconfig.json | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fetcher.ts b/src/fetcher.ts index d7d82f69c..b42e5f540 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -187,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 @@ -820,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' && @@ -855,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 @@ -1051,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 } @@ -1562,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) diff --git a/tsconfig.json b/tsconfig.json index 485ae3d98..b82a27d43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,6 @@ }, "include": [ "src/**/*" - ] + ], + "moduleResolution": "node" }