question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forget block crashes when removing node from ast

See original GitHub issue

When removing a node (in my case a propertyNode from a class) when inside a forget block, the forget block crashes when trying to clean up (forget) all nodes it doesn’t have to remember. The error thrown is:

Attempted to get information from a node that was removed or forgotten.

I tried remembering the node just before deleting it (with the same remember function, as well as in a new forget block), but it doesn’t seem to help.

ast.forgetNodesCreatedInBlock(remember => {
    ...
    remember(propertyNode); // Doesn't seem to help...
    propertyNode.remove();
    ...
});

gives:

Error: Attempted to get information from a node that was removed or forgotten.
    at InvalidOperationError.BaseError [as constructor] (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\errors\BaseError.js:16:28)
    at new InvalidOperationError (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:17:28)
    at PropertyDeclaration.get [as compilerNode] (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\compiler\common\Node.js:87:23)
    at PropertyDeclaration.Node.getKind (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\compiler\common\Node.js:138:21)
    at ForgetfulNodeCache.forgetNodes (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\factories\ForgetfulNodeCache.js:85:26)
    at ForgetfulNodeCache.forgetLastPoint (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\factories\ForgetfulNodeCache.js:51:18)
    at CompilerFactory.forgetNodesCreatedInBlock (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\factories\CompilerFactory.js:415:28)
    at TsSimpleAst.forgetNodesCreatedInBlock (C:\Users\niekj\projects\projects\apione\node_modules\ts-simple-ast\dist\TsSimpleAst.js:334:37)

It may also be interesting to investigate whether newly created nodes (created as in created with code generation/manipulation, not created from existing code) are forgotten as they should. This may have the same bug, only the other way around. It’s less impactfull as it doesn’t crash, but it may cause a performance issue with bigger projects.

I have currently commented out the forget blocks in the code as a workaround, but that may not be feasable when going to bigger test cases.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Nov 8, 2019

That’s ok! I’m thinking I could capture the stack at the moment it’s removed and then display that to the user in the error message as well. I know these can be hard to figure out sometimes (I’ve done it many times). Opened #751.

0reactions
dsherretcommented, Nov 9, 2019

@Roaders thanks! 😃 I’m glad it’s been useful for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove block crashing the game? : r/admincraft - Reddit
Go to your world folder, then go to serversettings Once there, edit the file calles forge.cfg (may have a different name cant remember...
Read more >
ast — Abstract Syntax Trees — Python 3.11.1 documentation
A with block. items is a list of withitem nodes representing the context managers, and body is the indented block ...
Read more >
Frequently Asked Questions - Slurm Workload Manager
What process should I follow to remove nodes from Slurm? ... some jobs submitted immediately before the slurmctld daemon crashed be lost?
Read more >
Top 10 Mistakes Node.js Developers Make - AirPair
1 Not using development tools. 1.1 Automating restarts; 1.2 Automatic browser refresh · 2 Blocking the event loop · 3 Executing a callback ......
Read more >
How to prevent your Node.js process from crashing - Medium
Remember: Always handle promise rejections. Listen to unhandled rejection events for crash reporting. And always use errors to reject promises ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found