-
Notifications
You must be signed in to change notification settings - Fork 929
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.