Skip to content

Conversation

cspotcode
Copy link
Contributor

@cspotcode cspotcode commented Oct 27, 2018

Splitting #40 into multiple PRs for easier review.

jbunton-atlassian and others added 7 commits October 27, 2018 15:52
…original

This stops a memory leak. The CallSite keeps a reference to Promise
objects. This stops the Promise from being garbage collected, which
stops asyncDestroy from being called.
- For each non-destroyed async context we store a `Trace` object in
  the global `traces` map.
- A trace object contains an array of `NamedStack` objects. This is
  simply a pair of `asyncId` and `frames`.
- Whenever a new async context is created we ask the trigger Trace
  to copy its `stacks` into the newly created Trace.
- The final long stack trace is assembled only if needed. This means
  tracking `executionScopeInits` is not necessary because we can do
  the stack trace deduplication later.
- Moved `equalCallSites` next to its caller, `extendFrames`
- `equalCallSites` treats anonymous stack frames as equal
Whenever a promise resolves we copy the trigger `Trace.stacks` into
the current async context's `Trace`. We also recursively copy it into
all related Traces.

This means any Error stacks that are extended from this point on will
contain the new frames.

Note this leaks lots of memory, see the next commit for some limits.
@AndreasMadsen
Copy link
Owner

I don't really understand what is going on here. Care to explain? "Fix" is also rather subjective. Following the resolve hook, it not a universally good idea.

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

Successfully merging this pull request may close these issues.

3 participants