rokid / node-webworker Goto Github PK
View Code? Open in Web Editor NEWThreads in Node.js with Web Worker
License: Apache License 2.0
Threads in Node.js with Web Worker
License: Apache License 2.0
i am trying to call a function inside worker using defines option. i would like to use request as require in worker is not supported.
any example would help?
Process 60651 launched: '/usr/local/bin/node' (x86_64)
TAP version 13
# single worker
ok 1 should be equal
Process 60651 stopped
* thread #7, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000100bcc88c node`worker + 54
node`worker:
-> 0x100bcc88c <+54>: movq %rax, (%rcx)
0x100bcc88f <+57>: movq (%rbx), %rax
0x100bcc892 <+60>: movq 0x8(%rbx), %rcx
0x100bcc896 <+64>: movq %rcx, 0x8(%rax)
Target 0: (node) stopped.
(lldb) bt
* thread #7, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x0000000100bcc88c node`worker + 54
frame #1: 0x00007fffc300e93b libsystem_pthread.dylib`_pthread_body + 180
frame #2: 0x00007fffc300e887 libsystem_pthread.dylib`_pthread_start + 286
frame #3: 0x00007fffc300e08d libsystem_pthread.dylib`thread_start + 13
fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
huangbinjie@~/workspace/yoi: (master) 🇨🇳 $ npm i webworker-ng
> [email protected] install /Users/huangbinjie/workspace/yoi/node_modules/webworker-ng
> node-gyp rebuild
CXX(target) Release/obj.target/webworker/src/WebWorkerWrap.o
In file included from ../src/WebWorkerWrap.cc:1:
In file included from .././src/WebWorkerWrap.h:6:
In file included from ../node_modules/nan/nan.h:192:
../node_modules/nan/nan_maybe_43_inl.h:112:15: error: no member named 'ForceSet'
in 'v8::Object'
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
~~~ ^
In file included from ../src/WebWorkerWrap.cc:1:
In file included from .././src/WebWorkerWrap.h:6:
../node_modules/nan/nan.h:834:18: warning: 'MakeCallback' is deprecated: Use
MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:171:1: note:
'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded
from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/WebWorkerWrap.cc:1:
In file included from .././src/WebWorkerWrap.h:6:
../node_modules/nan/nan.h:849:18: warning: 'MakeCallback' is deprecated: Use
MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:164:1: note:
'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded
from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/WebWorkerWrap.cc:1:
In file included from .././src/WebWorkerWrap.h:6:
../node_modules/nan/nan.h:864:18: warning: 'MakeCallback' is deprecated: Use
MakeCallback(..., async_context) [-Wdeprecated-declarations]
return node::MakeCallback(
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:157:1: note:
'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded
from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
In file included from ../src/WebWorkerWrap.cc:1:
In file included from .././src/WebWorkerWrap.h:6:
../node_modules/nan/nan.h:1473:31: warning: 'MakeCallback' is deprecated: Use
MakeCallback(..., async_context) [-Wdeprecated-declarations]
return scope.Escape(node::MakeCallback(
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:171:1: note:
'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded
from macro 'NODE_DEPRECATED'
__attribute__((deprecated(message))) declarator
^
../src/WebWorkerWrap.cc:21:26: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
char* text = strdup(*String::Utf8Value(info[0]));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:33:30: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
char* pathname = strdup(*String::Utf8Value(info[0]));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:62:36: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
worker->request_name = strdup(*String::Utf8Value(info[0]));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:63:36: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
worker->request_args = strdup(*String::Utf8Value(serializedParams.To...
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:97:24: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
char* id = strdup(*String::Utf8Value(info[0]));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:118:50: warning: 'Run' is deprecated
[-Wdeprecated-declarations]
Local<Value> result = script.ToLocalChecked()->Run();
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:1250:3: note: 'Run' has
been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version", Local<Value> Run());
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:141:58: warning: 'StackTrace' is deprecated
[-Wdeprecated-declarations]
Local<String> stack = Local<String>::Cast(try_catch->StackTrace());
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:8328:3: note:
'StackTrace' has been explicitly marked deprecated here
V8_DEPRECATED("Use maybe version.", Local<Value> StackTrace() const);
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:142:30: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
fprintf(stderr, "%s\n", *String::Utf8Value(stack));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
../src/WebWorkerWrap.cc:358:33: warning: 'Utf8Value' is deprecated
[-Wdeprecated-declarations]
worker->callback_id = strdup(*String::Utf8Value(info[0]));
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value'
has been explicitly marked deprecated here
V8_DEPRECATED("Use Isolate version",
^
/Users/huangbinjie/.node-gyp/10.0.0/include/node/v8config.h:321:29: note:
expanded from macro 'V8_DEPRECATED'
declarator __attribute__((deprecated))
^
13 warnings and 1 error generated.
make: *** [Release/obj.target/webworker/src/WebWorkerWrap.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/10.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/huangbinjie/workspace/yoi/node_modules/webworker-ng
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/huangbinjie/.npm/_logs/2018-05-03T11_42_28_718Z-debug.log
顺便问一句,共享数据方便传送到 worker 吗?
I am not sure where to use the params······
V8 startup takes huge time to up, for lightweight application, we should could choose which engine that we use. The candidates are:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.