socketio / socketio/socket.io-website

Step #7 Server delivery has multiple issues

Open
#512 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
342
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

When using the provided code, node will not run the .js file. Instead, there is the error:

  await db.each('SELECT id, content FROM messages WHERE id > ?',
  ^^^^^

SyntaxError: Unexpected reserved word
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:152:18)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:299:14)
at async link (node:internal/modules/esm/module_job:67:21)

I noticed several oddities in the example code. First, the word "async" is added to the line for "socket.on('chat message...", but was not highlighted. It's unclear if this is required for the displayed functionality, or is some option that was silently added without explaining to the reader/student.

I was able to get the .js file to run (by putting the highlighted "if (!socket.recovered)..." code inside the "socket.on('chat message..." expression), however, when a message is sent, not only is it displayed, but all previous messages are displayed, repeating the whole conversation each time a message is sent.

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.

Research direction

Start with the Step #7 Server delivery example and run the provided .js code to reproduce the syntax error and repeated-message behavior. Check the placement and highlighting of the async and recovery-related lines, then verify that the example runs, explains the required syntax, and displays each message only once.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.