Skip to content

Step #7 Server delivery has multiple issues #512

@Quin5

Description

@Quin5

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions