'window is not defined' in web worker. v2.1.5 only
With oboe in a web worker, I have no errors in v2.1.4 in v2.1.5, with no other code changes, I get error:
oboe-browser.js:2788 Uncaught ReferenceError: window is not defined
at streamingHttp (oboe-browser.js:2788)
at wire (oboe-browser.js:1024)
at applyDefaults (oboe-browser.js:980)
at oboe (oboe-browser.js:742)
at runXHR (grid.xhr.worker.js:9)
at grid.xhr.worker.js:34
streamingHttp @ oboe-browser.js:2788
wire @ oboe-browser.js:1024
applyDefaults @ oboe-browser.js:980
oboe @ oboe-browser.js:742
runXHR @ grid.xhr.worker.js:9
(anonymous) @ grid.xhr.worker.js:34
I'm using webpack and worker-plugin
I've tried various plugin configs:
plugins: [
// Tried all of these:
//new WorkerPlugin({ globalObject: `typeof self !== 'undefined' ? self : this`}),
//new WorkerPlugin({ globalObject: false}),
//new WorkerPlugin({ globalObject: 'this'}),
//new WorkerPlugin({ globalObject: 'self'}),
//new WorkerPlugin(),
]
Any ideas?
Have a test to recreate the issue at least. Will see if there are any work arounds and will look at a fix.
I have same error, in WEB worker only.
In browser main stread, no such issue.
I just comment out that line windows.timeout.....
although, no more error, but oboe stop working.
Please advise as soon as possible.
` xhr.withCredentials = withCredentials
xhr.send(data)
} catch (e) {
// window.setTimeout(
// Object(__WEBPACK_IMPORTED_MODULE_4__functional__["j" /* partialComplete */])(emitFail,
// Object(__WEBPACK_IMPORTED_MODULE_1__events__["o" /* errorReport */])(undefined,
//undefined, e))
// , 0
// )
}
}
`
It is this window not defined in web worker, please fix the bug.
`// To keep a consistent interface with Node, we can't emit an event here.
// Node's streaming http adaptor receives the error as an asynchronous
// event rather than as an exception. If we emitted now, the Oboe user
// has had no chance to add a .fail listener so there is no way
// the event could be useful. For both these reasons defer the
// firing to the next JS frame.
// window.setTimeout(
Object(__WEBPACK_IMPORTED_MODULE_4__functional__["j" /* partialComplete */])(emitFail,
Object(__WEBPACK_IMPORTED_MODULE_1__events__["o" /* errorReport */])(undefined, undefined,
e))
// , 0
// )
`
Good to know. Will look at refactoring that. I have been working on having a specific test that runs one in a worker. Has been going slowly. I want to make sure we don't run into something like this again.
A
On Mon 13 Jan 2020, 23:58 hoogw, [email protected] wrote:
I have same error,
I just comment out that line windows.timeout.....
it works
` xhr.withCredentials = withCredentials
xhr.send(data) } catch (e) { // window.setTimeout(// Object(WEBPACK_IMPORTED_MODULE_4__functional["j" /* partialComplete /])(emitFail, // Object(WEBPACK_IMPORTED_MODULE_1__events["o" / errorReport */])(undefined, //undefined, e)) // , 0 // )
} }
`
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/jimhigson/oboe.js/issues/201?email_source=notifications&email_token=ABG3J3QPEOYASLQMWKKNWULQ5T52TA5CNFSM4JK5FMF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI2YDSQ#issuecomment-573931978, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG3J3XAIAEDRAOKJ3L5ESDQ5T52TANCNFSM4JK5FMFQ .
Before you fix the bug in 2.15, windows.setTimeout().
Should be fairly easy fix ! In web worker, window object is undefined, cause error, you may want to re-write windows.setTimeout to something else to avoid error.
I have to use v2.14, it works fine in web worker. without issue.