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

'window is not defined' in web worker. v2.1.5 only #201

Open
thegoatherder opened this issue Nov 8, 2019 · 5 comments · May be fixed by #208
Open

'window is not defined' in web worker. v2.1.5 only #201

thegoatherder opened this issue Nov 8, 2019 · 5 comments · May be fixed by #208
Assignees

Comments

@thegoatherder
Copy link

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?

@Aigeec Aigeec self-assigned this Nov 13, 2019
@Aigeec
Copy link
Collaborator

Aigeec commented Nov 24, 2019

Have a test to recreate the issue at least. Will see if there are any work arounds and will look at a fix.

@hoogw
Copy link

hoogw commented Jan 13, 2020

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
   // )


   }
 }

`

@hoogw
Copy link

hoogw commented Jan 14, 2020

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
 // )

`

@Aigeec
Copy link
Collaborator

Aigeec commented Jan 14, 2020 via email

@hoogw
Copy link

hoogw commented Jan 14, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants