Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether you've looked into the source code but
this._targets
is a map ofTarget
instances. The assignment happens here:puppeteer/src/common/Browser.ts
Lines 350 to 361 in 44b22bb
The target's constructor might be doing some async work, but you can't mark a constructor as
async
and await the class instantiation (i. e.await new Target(...)
is not possible). The instance will be immediately returned and the constructor's async work happens afterwards in the background.Did you actually try building puppeteer with this change to see whether this fixes the issue for you?
Edit: the only thing I could imagine is that adding the
await
would defer this line to be executed later (i. e. pushes it to the end of the event loop). I just did a search and it seems like that's how it works according to this SO answer ("if you await things you will always defer the continuation to a microtask"). TIL 🤓@mathiasbynens referring to #7351 (comment), is it possible that the
await
deferring did actually have an effect?