Why is an error falsely happening? [FIXED]

Getting this error in the console with the default fastify. listen()

SyntaxError: Unexpected end of input

    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Code:


fastify.listen(
  { port: process.env.PORT, host: "0.0.0.0" },
  function (err, address) {
    if (err) {
      console.error(err);
      process.exit(1);
    }
    console.log(`Your app is listening on ${address}`);
  }
);

This is on a very popular website (maybe one of the most) hosted here on glitch and needs to be fixed asap

Could you post your solution in case it helps others in the future?

2 Likes

doesn’t say which file had the syntax error?

UPDATE

This happens occasionally on javascript files where it is giving this error saying that there is a bad character at the end of the script, which isn’t visible to us. The fix is to rewind the glitch project one save back which somehow straightens out the code. This is probably some bad code on glitch’s end that need to be fixed.

This seems to have been happening for many years now

1 Like

huh but why wouldn’t it have that file name in syntax error info?

Probably because it was the server.js and all the errors from that file go to the bulit in console