-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
util.isNode / Error: not supported #1221
Comments
The check is here: https://github.com/protobufjs/protobuf.js/blob/master/src/util/minimal.js#L55 There might be something in your stack invalidating it, or did node change something? Workaround: protobuf.util.isNode = true; // or your own check
... |
I'm having a similar, so what I found worked (which I don't think would be a hard/serious change) is in util.global = typeof window !== "undefined" && window
|| typeof global !== "undefined" && global
|| typeof self !== "undefined" && self
|| this; // eslint-disable-line no-invalid-this And I swapped it to this: util.global = typeof global !== "undefined" && global
|| typeof window !== "undefined" && window
|| typeof self !== "undefined" && self
|| this; // eslint-disable-line no-invalid-this I'm using mocha with jsdom so the window object is passing first and therefore being set as the global, not the NodeJS.Global! But if I swap the order it works fine. Could this be implemented into the regular library? |
Hmm, good question. The old order assumes that a global |
I believe this may be a conflict with NestJS people use a lot for SSR: If protobuf.js is initialized first, there is no error with isNode mode detection. |
That makes sense. |
It's also an issue if you are using |
EDIT: wrote an article about how I fixed this with angular SSR: https://medium.com/@michele.patrassi/angular-ssr-firebase-save-days-of-debugging-by-reading-these-fixes-fcb060e248bb OLD There are some valid comments up in the thread: what's the best way to approach this? |
* Fixes #1221 when used within SSR. `process` is a global variable since node [0.1.7](https://nodejs.org/api/globals.html#globals_process) and versions since [0.2.0](https://nodejs.org/api/process.html#process_process_versions). Co-authored-by: Alexander Fenster <fenster@google.com>
* Fixes protobufjs#1221 when used within SSR. `process` is a global variable since node [0.1.7](https://nodejs.org/api/globals.html#globals_process) and versions since [0.2.0](https://nodejs.org/api/process.html#process_process_versions). Co-authored-by: Alexander Fenster <fenster@google.com>
* Fixes protobufjs/protobuf.js#1221 when used within SSR. `process` is a global variable since node [0.1.7](https://nodejs.org/api/globals.html#globals_process) and versions since [0.2.0](https://nodejs.org/api/process.html#process_process_versions). Co-authored-by: Alexander Fenster <fenster@google.com>
protobuf.js version: 6.8.8
Ubuntu: 19.04
Node: 12.2.0
Angular: 7.2.15 with server-side rendering enabled
I'm seeing "Error: not supported" popping up in an Angular 7 app on Node 12.2.0. Just upgraded Node from 10.15.3, where it did not have the error.
After a little digging, it looks like this references /src/root.js:233-234:
and /src/util/minimal.js:55:
After commenting out the check in root.js, everything seems to work fine. Is there another solution?
The text was updated successfully, but these errors were encountered: