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

socket.io dosn't run in VM "sandboxed-module" #2381

Closed
mStirner opened this issue Jan 10, 2016 · 9 comments
Closed

socket.io dosn't run in VM "sandboxed-module" #2381

mStirner opened this issue Jan 10, 2016 · 9 comments

Comments

@mStirner
Copy link

Hay, i have a little problem.

I cant use socket.io inside a node js VM.
When i run it i become this error: "TypeError: Cannot read property 'prototype' of undefined"

/home/marc/NetBeansProjects/Project/node_modules/socket.io-client/node_modules/json3/lib/json3.js:50
var objectProto = Object.prototype,
^
TypeError: Cannot read property 'prototype' of undefined
at runInContext (/home/marc/NetBeansProjects/Project/node_modules/socket.io-client/node_modules/json3/lib/json3.js:50:29)

As VM i use the module "sandboxed-module"

@mStirner
Copy link
Author

I found a "Quick & Dirty" Solution:

The problem is the "json3" module.
I added in the function "runInContext" (path: json3/lib/json3.js) before:

context || (context = root["Object"]());
exports || (exports = root["Object"]());

this line:

root = global;

final:

root = global;
context || (context = root["Object"]());
exports || (exports = root["Object"]());

Now it works, but is this the fine way ?
Or have i problems with the configuration of the vm ?

@nkzawa
Copy link
Contributor

nkzawa commented Jan 17, 2016

This one https://github.com/felixge/node-sandboxed-module ? I'm not familiar with the module, but that sounds the issue of vm module to me.

@mStirner
Copy link
Author

Yep., it is the module.
What do the vm wrong ?

@nkzawa
Copy link
Contributor

nkzawa commented Jan 17, 2016

I'm not sure if the vm module is wrong, but I don't think we can do something to solve the problem. Can you create the issue on node-sandboxed-module or json3 instead?

@mStirner
Copy link
Author

json3 module issues: bestiejs/json3#86
vm module issues: felixge/node-sandboxed-module#55

@dozoisch
Copy link

dozoisch commented Apr 21, 2016

I'm hitting exactly the same issue in a WebWorker with socket.io-client@1.4.5. Trying to figure out a work around. The issue seems to originate from json3. At least I can still downgrade back to socket.io-client@1.3.7, it was working fine on that version.

@ghost
Copy link

ghost commented Jul 28, 2016

@dozoisch cheers, looking at a workaround as well but rolling back to 1.3.7 sorted the issue for now.

👍

@chge
Copy link

chge commented Sep 26, 2016

It's sandboxed-module issue.

@darrachequesne
Copy link
Member

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

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

No branches or pull requests

6 participants
@chge @nkzawa @dozoisch @mStirner @darrachequesne and others