screeps-typescript-starter
screeps-typescript-starter copied to clipboard
Source Map dosen't work in some scenarios. Possible fix.
Testcase :
at RoomPosition.inRangeTo (:14512:20)
at Object.Creep.meeleAttackTarget (main:4335:18)
at attack$1 (main:310:11)
at run$9 (main:324:9)
at ErrorMapper.wrapLoop (main:4919:13)
at Object.loop (main:4097:17)
at __module (__mainLoop:1:52)
at __mainLoop:2:3
at Object.exports.evalCode (:15845:76)
at Object.exports.run (:46468:24)
I think if you take a look at the error ErrorMapper.ts at this line you are checking if it is coming from the main file and breaking. Sometimes the first match doesn't necessarily come from main as seen in the above stack trace.
The possible solution for this was to remove the corresponding else block. While this solves this case I'm not sure if it is a general solution.
I'm not that familiar with the workings of the ErrorMapper. The current set-up bundles everything into dist/main.js. Any errors originating from player code would then be coming from there, at some level.
Do you have any test code to reproduce the referenced stack trace? What is your project structure, is everything bundled? Are you getting any output from the ErrorMapper?
What is your project structure, is everything bundled?
I follow the same folder structure as this project. By bundled if you mean everything is added to one single main.js file, then yes. Bellow is my project strucuture

Any errors originating from player code would then be coming from there, at some level.
You are right, I was confused by this too. Will do a deep dive today on this bug and let you know
Okay I was able to reproduce it.
I changed my core loop to the following one line code :
export const loop = ErrorMapper.wrapLoop(() => {
// @ts-ignore
Game.creeps.Attacker_2179.pos.inRangeTo(undefined, 4);
});
I added a line to errorMapper.ts to also print out the original stack trace (coloured white in the below image)
else {
console.log(`<span style='color:#ff4444'>${this.sourceMappedStackTrace(e)}</span>`);
console.log(e.stack);
}
Here is the console output :
The red stack trace is only apearing correctly because of the fix I provided in the first post.

Thanks for the reproducible instructions. I'll take a look at your suggestion for fixing it.
On Thu, 19 Aug 2021, 07:27 Akshay.L.Aradhya, @.***> wrote:
Okay I was able to reproduce it.
I change my core loop to the following one line code :
export const loop = ErrorMapper.wrapLoop(() => { // @ts-ignore Game.creeps.Attacker_2179.pos.inRangeTo(undefined, 4);});
I added a line to errorMapper to also printed out the original stack trace (coloured white in the below image)
else { console.log(
<span style='color:#ff4444'>${this.sourceMappedStackTrace(e)}</span>); console.log(e.stack);}Here is the console output : [image: image] https://user-images.githubusercontent.com/6565924/130007445-eb8578e1-dac4-4bc7-b73d-ea170dc0e616.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/screepers/screeps-typescript-starter/issues/159#issuecomment-901600035, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQMB3CUJYJD3B6TBYLGHDT5SBZ7ANCNFSM5CF7K5UQ .