socketcluster
socketcluster copied to clipboard
When trying to require scworker.js or scbroker.js directly, throw a better error
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.
I've the same issue.
@jondubois Are there any plans to tackle this issue? Currently trying to write unit tests for my worker and am seeing this error message.