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

Source Map dosen't work in some scenarios. Possible fix. #159

Open
DollarAkshay opened this issue Aug 15, 2021 · 4 comments
Open

Source Map dosen't work in some scenarios. Possible fix. #159

DollarAkshay opened this issue Aug 15, 2021 · 4 comments

Comments

@DollarAkshay
Copy link

DollarAkshay commented Aug 15, 2021

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.

@pyrodogg
Copy link
Member

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?

@DollarAkshay
Copy link
Author

DollarAkshay commented Aug 19, 2021

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
image

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

@DollarAkshay
Copy link
Author

DollarAkshay commented Aug 19, 2021

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.
image

@pyrodogg
Copy link
Member

pyrodogg commented Aug 19, 2021 via email

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

2 participants