bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

json3 dosn't run in VM #86

Open mStirner opened 8 years ago

mStirner commented 8 years ago

Hay, i have a little problem.

I cant use json3 (socket.io, btw. socket.io-client) 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" (https://github.com/felixge/node-sandboxed-module)

See other issue on: https://github.com/socketio/socket.io/issues/2381#issuecomment-172353479

dozoisch commented 8 years ago

I'm hitting the same issue in a WebWorker in an iOS webview

GeoffreyPlitt commented 8 years ago

+1

chge commented 8 years ago

It's sandboxed-module issue.

raine commented 5 years ago

Same issue when importing json3 in a web worker using parcel.

webees commented 5 years ago

The same problem,in Electron,use SocketIO through webWorker,:

import { BitcoreBlockchain } from 'hd-wallet'

import SocketWorker from 'worker-loader?name=js/socketio-worker.[hash].js!hd-wallet/lib/socketio-worker/inside'

const blockchain = new BitcoreBlockchain(['https://btc4.trezor.io'], () => new SocketWorker())

_20190131120200

https://github.com/trezor/hd-wallet

Solution: nodeIntegrationInWorker: true

https://github.com/electron/electron/blob/master/docs/tutorial/multithreading.md