josdejong / workerpool

Offload tasks to a pool of workers on node.js and in the browser
Apache License 2.0
2.04k stars 148 forks source link

Workerpool Error when using webpack #410

Closed mai1x9 closed 9 months ago

mai1x9 commented 9 months ago

I am getting below error afgter building the node application with webpack.

ReferenceError: _0x47d6cd is not defined
    at _0x27c0a8 (eval at run (/home/ubuntu/build-client-v1.0.0/node_modules/workerpool/src/worker.js:98:11), <anonymous>:3:105)
    at Function.eval (eval at run (/home/ubuntu/build-client-v1.0.0/node_modules/workerpool/src/worker.js:98:11), <anonymous>:3:5003)
    at Function.run (/home/ubuntu/build-client-v1.0.0/node_modules/workerpool/src/worker.js:99:12)
    at MessagePort.<anonymous> (/home/ubuntu/build-client-v1.0.0/node_modules/workerpool/src/worker.js:150:27)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:643:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)
  app:tls Client has swiftly closed the connection , end points : 4.246.219.128:6767, pid: 5303 +203ms
  app:tls EOT (End Of Transmission/ close ) +1ms

Since i am using webpack, the js code is obfuscated, all I know is error at line 98. However if run as direct node application without building using webpack it is working.

I am not sure what is the reason behind it, but probably eslint might help to figure out reference errors and fix them.

Any help or suggestion regarding this.

josdejong commented 9 months ago

How can we reproduce this issue?

mai1x9 commented 9 months ago

@josdejong thanks for response. I could figure out the issue is not due to workerpool. It is due to webpack. After thorough references to: https://github.com/javascript-obfuscator/javascript-obfuscator/issues/195 and https://github.com/javascript-obfuscator/javascript-obfuscator/issues/207 I could see that the issue is due to webpack.


When the function is passed as argument, it is resulting in reference error. (I am not sure why obfuscation is throwing the error). However as a work around, I have just excluded couple of lines where worker-pool is used preventing from obfuscating the code and it is working now.

I think the issue is due to some scope or dead-code injection etc..

josdejong commented 9 months ago

Good to hear you found the cause. Closing this issue now.