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

No log.entryAdded after navigation #620

Closed
Lightning00Blade opened this issue Apr 17, 2023 · 4 comments
Closed

No log.entryAdded after navigation #620

Lightning00Blade opened this issue Apr 17, 2023 · 4 comments
Assignees

Comments

@Lightning00Blade
Copy link
Collaborator

If we navigate to a page that log things on load (ReadinessState == 'complete').
An repo Puppeteer Script be seen at #10032.

After an investigation I was able to deduce that the RealmStorage is being cleared by the CDP Page.frameNavigated event.
And the Runtime.executionContextCreated event creates a new Realm.
The first event handler is Async while the second is Sync. I think we are creating a new Realm then the first is awaited and we delete all the old Realms for the BrowsingContext included the newly created on.

The line that is doing this.

If I reorder the this.#realmStorage.deleteRealms before await this.#deleteChildren(); things work as expected.
Please check if there is a specific reason for the current order of operation.

@thiagowfx
Copy link
Contributor

I wonder if we can replace

await this.#deleteChildren();

// Remove all the already created realms.
this.#realmStorage.deleteRealms({browsingContextId: this.contextId});

with

this.delete();

?

@thiagowfx
Copy link
Contributor

I cannot reproduce it in BiDi. The following test passes:

@pytest.mark.asyncio
async def test_browsingContext_logAfterNavigation(websocket, context_id, html):
    await subscribe(websocket, "log.entryAdded")

    await send_JSON_command(
        websocket, {
            "method": "browsingContext.navigate",
            "params": {
                "url": html("<script>console.log('mylog');</script>"),
                "context": context_id,
                "wait": "complete"
            }
        })

    result = await wait_for_event(websocket, "log.entryAdded")
    assert result == {
        "method": "log.entryAdded",
        "params": AnyExtending({
            "text": "mylog",
        })
    }

@thiagowfx
Copy link
Contributor

@sadym-chromium let me know if you manage to create a repro.

thiagowfx added a commit that referenced this issue Apr 17, 2023
@Lightning00Blade
Copy link
Collaborator Author

I can confirm that the suggestion in comment works, as long as it's not awaited.

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

3 participants