xxscreeps icon indicating copy to clipboard operation
xxscreeps copied to clipboard

Server crash 1-2 ticks after start

Open Gadjung opened this issue 3 years ago • 10 comments

win10, Node 16.6.1, running via VS 2019 terminal with and without default mods, tick speed does not change anything either:

mods:
  - xxscreeps/mods/classic
  - xxscreeps/mods/backend/cookie
  - xxscreeps/mods/backend/password
  - xxscreeps/mods/backend/steam

on clean copy of xxscreeps, after

  • npm install
  • npm run build
  • npx xxscreeps import

running npx xxscreeps start starts server, but after 1-3 long ticks (configured to 1s in config) an error is thrown:

PS K:\xxscreeps_fork> npx xxscreeps start
🌎 Listening
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 1
Tick 1 ran in 5026ms; avg: 5025.55ms
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 2
Tick 2 ran in 5010ms; avg: 5010.11ms
node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ("export 'install' (imported as 'SourceMap') was not found in 'source-map-support' (module has no exports)")
    at new NodeError (node:internal/errors:371:5)
    at Worker.emit (node:events:383:17)
    at Worker.[kOnErrorMessage] (node:internal/worker:298:10)
    at Worker.[kOnMessage] (node:internal/worker:309:37)
    at MessagePort.<anonymous> (node:internal/worker:210:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'ERR_UNHANDLED_ERROR',
  context: "export 'install' (imported as 'SourceMap') was not found in 'source-map-support' (module has no exports)"
}

on subsequent tries of npx xxscreeps start the error pops immediately (no ticks processed) problem seems to steam from source-map.ts

i tried installing it globally but nothing changed

issue started around 30 Aug so i tried some older commits bae0f5ea00d557c49161a8fb9cc416d4c1a566f8 and b104d94c85f7f8976a86568d1dfea4db1d0972d7 but nothing changed

Gadjung avatar Sep 03 '21 14:09 Gadjung

This isn't the experience that other users are having. I tested this from scratch using a fresh local account and it's working fine over here. Since it's not fixing itself when you rewind to an old commit it really seems like this is something local to your computer. Please do some digging and see if you can figure this out.

laverdet avatar Sep 03 '21 15:09 laverdet

i checked for older version of source-map package - no change for now. will try to look some more when i get a moment

Gadjung avatar Sep 06 '21 10:09 Gadjung

reinstalling node (using nvm) to newest 16.8.0 version did not help

after commenting out the source-map part that caused the crash, i started getting

node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ("export 'default' (imported as 'lodash') was not found in 'lodash' (module has no exports)")
    at __node_internal_captureLargerStackTrace (node:internal/errors:464:5)
    at new NodeError (node:internal/errors:371:5)
    at Worker.emit (node:events:383:17)
    at Worker.[kOnErrorMessage] (node:internal/worker:298:10)
    at Worker.[kOnMessage] (node:internal/worker:309:37)
    at MessagePort.<anonymous> (node:internal/worker:210:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'ERR_UNHANDLED_ERROR',
  context: "export 'default' (imported as 'lodash') was not found in 'lodash' (module has no exports)"

Gadjung avatar Sep 06 '21 15:09 Gadjung

sam happens if i change

SourceMap.install({ ... })

to

require('source-map-support').install({ ...})

quite out of ideas, i've also tried installing on different drive, but same bucket of issues

Gadjung avatar Sep 06 '21 16:09 Gadjung

I have been experiencing the same issue on the following environment

  • Windows 10
  • Node v16.4.0

I got no mods installed, just freshly cloned this repo and follow the steps:

npm install
npm run build
npx xxscreeps import
npx xxscreeps start

Here is what I get:

$ npx xxscreeps start
🌎 Listening
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 1
Tick 1 ran in 5021ms; avg: 5020.73ms

node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ("export 'install' (imported as 'SourceMap') was not found in 'source-map-support' (module has no exports)")
    at __node_internal_captureLargerStackTrace (node:internal/errors:456:5)
    at __node_internal_addCodeToName (node:internal/errors:191:9)
    at new NodeError (node:internal/errors:363:5)
    at Worker.emit (node:events:383:17)
    at Worker.[kOnErrorMessage] (node:internal/worker:298:10)
    at Worker.[kOnMessage] (node:internal/worker:309:37)
    at MessagePort.<anonymous> (node:internal/worker:210:57)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:461:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'ERR_UNHANDLED_ERROR',
  context: "export 'install' (imported as 'SourceMap') was not found in 'source-map-support' (module has no exports)"
}

geocine avatar Nov 29 '21 12:11 geocine

When I actually remove the call to source-map-support then got it building. It moved to another module and emitted the same error lodash. I think the issue is not in the modules, it is somewhere else.

EDIT: It's same as you experienced here https://github.com/laverdet/xxscreeps/issues/36#issuecomment-913730173

geocine avatar Nov 30 '21 02:11 geocine

Hmm, had an old install and I fetched the latest code and got this error windows 10 node v16.8.0

thmsn@thmsn MINGW64 /c/Projects/Screeps/xxscreeps (misc/manual-roadmap)
$ npx xxscreeps start
🌎 Listening
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 1
Tick 1 ran in 5716ms; avg: 5716ms
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 2
Tick 2 ran in 5621ms; avg: 5621.4ms

node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
export 'install' (imported as 'SourceMap') was not found in 'source-map-support' (module has no exports)
(Use `node --trace-uncaught ...` to show where the exception was thrown)

I was using "webpack": "5.51.1" and stumpled upon this issue https://github.com/webpack/webpack/issues/8302 npm install webpack@latest updated it to "webpack": "^5.65.0" but it still failed with the same error

npm outdated lists source-map-support as outdated but updating to "^0.5.21", still fails

The issue I found earlier mentions https://github.com/webpack/webpack-sources/pull/41 whitespaces causing invalid source maps and ESLint is whining about LF vs CLRF (I am on windows) image

As far as I can see source-map-support should be exporting an install method, but perhaps it is not properly picked up by webpack? https://github.com/evanw/node-source-map-support/blob/ac2c3e4c633c66931981ac94b44e6963addbe3f4/source-map-support.js#L528

Changing it to import { install } from 'source-map-support'; did not seem to work either the source-map-support.js from the node modules folder seems to be doing exports.install = function(options) {

found this open issue on nodejs https://github.com/nodejs/help/issues/3163 that links to this https://nodejs.org/api/esm.html#esm_mandatory_file_extensions that mentions this https://github.com/nodejs/cjs-module-lexer/tree/1.2.2#parsing-examples

is it simply because no exports are detected from the source-map-support.js for some reason?

Found this issue as well on the source-map-support repo Cannot find module 'source-map' from 'source-map-support.js'

The last thing I've done is deleting the screeps folder and running npx xxscreeps import but it still gives the error. I've got no other ideas currently in regards what to do. but it does seem to be a windows problem

@laverdet If you can find some free time to perhaps help with debugging and solving this, windows users might be able to help with progress on the project :) I'll gladly assist in debugging it, I just have no clue as to what else we can do to figure it out.

thmsndk avatar Dec 11 '21 23:12 thmsndk

When I actually remove the call to source-map-support then got it building. It moved to another module and emitted the same error lodash. I think the issue is not in the modules, it is somewhere else.

EDIT: It's same as you experienced here #36 (comment)

I got the same if I removed loadSourceMap(url, content as string) from runtime/module.ts the following error was thrown

node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
export 'default' (imported as 'lodash') was not found in 'lodash' (module has no exports)
(Use `node --trace-uncaught ...` to show where the exception was thrown)

I found this issue an issue saying import * as _ from "lodash"; is the only thing that works, but did changed nothing except for the error message

node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^
export 'iteratee' (imported as '_') was not found in 'lodash' (module has no exports)
(Use `node --trace-uncaught ...` to show where the exception was thrown)

I tried fiddling around and disabling things but that is a deep rabithole, it seems a lot like something is wonky in regards to webpack loading modules that perhaps are writtin in a specific way and use a specific module loader? at least in windows.

thmsndk avatar Dec 12 '21 11:12 thmsndk

Okay so using dev containers with visual studio code form this PR https://github.com/laverdet/xxscreeps/pull/48 allows me to run the server.

I do however get the following errors after 2 ticks, the server recovers and continues though. could they perhaps be related, or is that another issue?

root@docker-desktop:/workspaces/xxscreeps# npx xxscreeps start
🌎 Listening
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 1707
Tick 1707 ran in 6289ms; avg: 6288.91ms
Abandoning intents in rooms [W1N1, W1N9, W9N1, W9N9] for tick 1708
Tick 1708 ran in 5070ms; avg: 5069.68ms
/workspaces/xxscreeps/src/engine/db/shard.ts:133
                                throw new Error(`Invalid time: ${time} [current: ${this.time}]`);
                                      ^

Error: Invalid time: 1706 [current: 1708]
    at Shard.checkTime (/workspaces/xxscreeps/src/engine/db/shard.ts:133:11)
    at Shard.loadRoomBlob (/workspaces/xxscreeps/src/engine/db/shard.ts:96:3)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:171:27)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:168:5)
    at PlayerInstance.run (/workspaces/xxscreeps/src/engine/runner/instance.ts:124:18)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/service/runner.ts:104:7)
/workspaces/xxscreeps/src/engine/db/shard.ts:133
                                throw new Error(`Invalid time: ${time} [current: ${this.time}]`);
                                      ^

Error: Invalid time: 1706 [current: 1708]
    at Shard.checkTime (/workspaces/xxscreeps/src/engine/db/shard.ts:133:11)
    at Shard.loadRoomBlob (/workspaces/xxscreeps/src/engine/db/shard.ts:96:3)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:171:27)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:168:5)
    at PlayerInstance.run (/workspaces/xxscreeps/src/engine/runner/instance.ts:124:18)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/service/runner.ts:104:7)
/workspaces/xxscreeps/src/engine/db/shard.ts:133
                                throw new Error(`Invalid time: ${time} [current: ${this.time}]`);
                                      ^

Error: Invalid time: 1706 [current: 1708]
    at Shard.checkTime (/workspaces/xxscreeps/src/engine/db/shard.ts:133:11)
    at Shard.loadRoomBlob (/workspaces/xxscreeps/src/engine/db/shard.ts:96:3)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:171:27)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:168:5)
    at PlayerInstance.run (/workspaces/xxscreeps/src/engine/runner/instance.ts:124:18)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/service/runner.ts:104:7)
/workspaces/xxscreeps/src/engine/db/shard.ts:133
                                throw new Error(`Invalid time: ${time} [current: ${this.time}]`);
                                      ^

Error: Invalid time: 1706 [current: 1708]
    at Shard.checkTime (/workspaces/xxscreeps/src/engine/db/shard.ts:133:11)
    at Shard.loadRoomBlob (/workspaces/xxscreeps/src/engine/db/shard.ts:96:3)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:171:27)
    at async Promise.all (index 0)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/runner/instance.ts:168:5)
    at PlayerInstance.run (/workspaces/xxscreeps/src/engine/runner/instance.ts:124:18)
    at null.<anonymous> (/workspaces/xxscreeps/src/engine/service/runner.ts:104:7)
Tick 1709 ran in 3082ms; avg: 4076.02ms

thmsndk avatar Dec 12 '21 11:12 thmsndk

I do wonder if the engine error throw new Error(`Invalid time: ${time} [current: ${this.time}]`); from the server itself is tripping up the sourcemap / module loader and that is the issue we experience on windows?

thmsndk avatar Dec 12 '21 12:12 thmsndk