Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server crash 1-2 ticks after start #36

Open
Gadjung opened this issue Sep 3, 2021 · 10 comments
Open

Server crash 1-2 ticks after start #36

Gadjung opened this issue Sep 3, 2021 · 10 comments

Comments

@Gadjung
Copy link

Gadjung commented Sep 3, 2021

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

@laverdet
Copy link
Owner

laverdet commented Sep 3, 2021

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.

@Gadjung
Copy link
Author

Gadjung commented Sep 6, 2021

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
Copy link
Author

Gadjung commented Sep 6, 2021

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
Copy link
Author

Gadjung commented Sep 6, 2021

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

@geocine
Copy link

geocine commented Nov 29, 2021

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
Copy link

geocine commented Nov 30, 2021

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)

@thmsndk
Copy link
Contributor

thmsndk commented Dec 11, 2021

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 webpack/webpack#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 webpack/webpack-sources#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 nodejs/help#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
Copy link
Contributor

thmsndk commented Dec 12, 2021

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
Copy link
Contributor

thmsndk commented Dec 12, 2021

Okay so using dev containers with visual studio code form this PR #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
Copy link
Contributor

thmsndk commented Dec 12, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants