Skip to content

Conversation

@pavelfeldman
Copy link
Member

Fixes #37421

"version": "0.0.0",
"type": "module",
"dependencies": {
"idb-keyval": "^6.2.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpacked Size
928 kB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sw.bundle.js

before
220990
after
223446

Co-authored-by: Yury Semikhatsky <[email protected]>
Signed-off-by: Pavel Feldman <[email protected]>
@github-actions

This comment has been minimized.

@pavelfeldman pavelfeldman merged commit 25f89ac into microsoft:main Sep 17, 2025
34 of 35 checks passed
@github-actions
Copy link
Contributor

Test results for "tests 1"

1 failed
❌ [playwright-test] › runner.spec.ts:118 › should ignore subprocess creation error because of SIGINT @macos-latest-node18-1

7 flaky ⚠️ [chromium-library] › library/inspector/cli-codegen-aria.spec.ts:76 › should update aria snapshot highlight `@chromium-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-pick-locator.spec.ts:35 › should update locator highlight `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-ubuntu-22.04-node18`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:397 › should work behind reverse proxy `@macos-latest-node18-1`
⚠️ [webkit-library] › library/browsercontext-add-cookies.spec.ts:426 › should allow unnamed cookies `@webkit-ubuntu-22.04-node18`
⚠️ [webkit-library] › library/video.spec.ts:378 › screencast › should capture navigation `@webkit-ubuntu-22.04-node18`

46869 passed, 821 skipped


Merge workflow run.

Copy link
Contributor

@cpAdm cpAdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavelfeldman Thanks for the effort! Unfortunately, it is not quite fixed, due to the /ping calling gc before we reload the traces, see PR comment.

const oldValue = await idbKeyval.get('clientIdToTraceUrls');
if (newValue === oldValue)
return;
idbKeyval.set('clientIdToTraceUrls', newValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to await this

loadedTraces.delete(traceUrl);
}

await saveClientIdParams();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saving here is troublesome:

When we re-open the browser tab, the service worker starts again, and the /pings requests come in, which will call gc.
At this point clientIdToTraceUrls is empty and thus we clear the database, even tough this client has traces.

So, I suggest to either only call saveClientIdParams if we call clientIdToTraceUrls.delete
and/or move the if (!clientIdToTraceUrls.has(event.clientId)) { check before the /ping handling.

const params = await loadClientIdParams(event.clientId);
if (params) {
for (const traceUrl of params.traceUrls)
await loadTrace(traceUrl, null, client, params.limit, () => {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadTrace also calls gc. Not really what we need here, but not sure if that can cause (concurrency) issues?

Maybe move gc out of loadTrace and just call it in the relativePath === '/contexts' branch?

}
}

if (!clientIdToTraceUrls.has(event.clientId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the 'trace/snapshot/' client this will always be true.

* limitations under the License.
*/

import * as idbKeyval from 'idb-keyval';

This comment was marked as resolved.

This comment was marked as resolved.

await saveClientIdParams();
}

// Persist clientIdToTraceUrls to localStorage to avoid losing it when the service worker is restarted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically IndexDB !== localStorage

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.

[Bug]: Response body in trace viewer shows empty after some idle time

3 participants