SocketCluster / SocketCluster/socketcluster

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

Open
#347 2 comments 1 reaction 1 assignee View on GitHub

@jondubois is already working on this.

Since Apr 7, 2018.

Dominant language
JavaScript
Stars
6.2k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.