Conversation
Detach the owned frame listener on destroy and reinitialization. Guard pre-injection continuations against a replaced page registration, including synchronous disconnected listeners. Keep the navigation rejection handling proposed in wwebjs#201893 separate. Add account-free lifecycle regressions and document their runner. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Clear the previous page's logout flag when initialization starts. Add a regression for normal navigation after destroy and reinitialize. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Stop a navigation task from an old Client page from resuming auth setup or
starting injection after destroy/reinitialization.
The handler now captures its page and registration, checks that ownership before
each remaining pre-injection step, and is detached at destroy or initialization
start without removing listeners owned by callers. A new initialization resets
the old page's logout flag. Normal logout still runs its auth hooks and forces
reinjection on the current page; genuine initialization errors still reject.
This is a separate lifecycle follow-up, not a competing implementation of
#201893's navigation rejection handling. That PR already fixes both reproduced
context-loss crashes, including the newer-document-already-wired case. Its
current head still fails the old-logout/destroy/reinitialize continuation case.
This change adds no queue, binding-error suppression,
inject_errorcontract,timer polling, or initialize-failure browser cleanup.
This change invalidates remaining handler continuations; it does not cancel
auth-hook internals or an injection body that has already started. The original
navigation crash boundary remains the responsibility of #201893.
Related Issue(s)
Fixes #201941
Follow-up to merged #201653 and related to #201893. The original crash
regression evidence is recorded at
#201893 (comment).
This PR addresses the distinct stale-handler lifecycle gap. #201897 is
explicitly out of scope.
Testing Summary
Test Details
npm run test-single -- tests/client-navigation.js: 19 passing.The same final file against main
064a3d5gives 8 passing, 11 failing.fresh offline Chromium pages: guards, genuine initialization rejection,
normal logout, and old logout across full destroy/reinitialization all pass
(4 passing). New-page navigation no longer inherits the old logout.
064a3d5and fix(client): prevent concurrent injection crash #201893 head4d1f29e; auth-hook/injection counts grow from[1,1,1]to[2,2,2].With this change they stay
[1,1,1]../node_modules/.bin/eslint src/Client.js tests/client-navigation.js: pass../node_modules/.bin/prettier --check src/Client.js tests/client-navigation.js tests/README.md: pass.node --check src/Client.js,node --check tests/client-navigation.js,and
git diff --check: pass.npm testrequires real accountconfiguration and sends messages, so it was not run. No live WhatsApp
end-to-end testing is claimed.
Environment
064a3d5a5a3dce1281a6a12740b5a7051339d154Type of Change
Checklist
npm test).index.d.ts) have been updated if necessary (no public API/type changes).example.js) / documentation have been updated if applicable (tests/README.md).The full-test checkbox is intentionally unchecked: only the account-free scope
above was run.