socketcluster icon indicating copy to clipboard operation
socketcluster copied to clipboard

When trying to require scworker.js or scbroker.js directly, throw a better error

Open jondubois opened this issue 8 years ago • 2 comments

Currently, if someone tries to require scworker.js directly into another script without first setting up the correct environment variables, it will throw this error:

SyntaxError: Unexpected token u in JSON at position 0

Generally, scworker.js should not be included directly into a Node.js script; it should be loaded by SC itself but it should at least be supported for unit testing purposes.

The current error should be improved to make this more clear.

Should be done for both scworker.js and scbroker.js.

jondubois avatar Dec 10 '17 19:12 jondubois

I've the same issue.

brunoalano avatar Mar 20 '18 22:03 brunoalano

@jondubois Are there any plans to tackle this issue? Currently trying to write unit tests for my worker and am seeing this error message.

alekhinen avatar Sep 09 '19 19:09 alekhinen