-
Notifications
You must be signed in to change notification settings - Fork 4
chore(sdk): cap browser heap in huge.spec.ts to catch memory leaks #925
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
Changes from all commits
fe115e6
151bccd
4cdfd40
2859576
c9359d2
7a9ba69
a64703e
66c2e73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,12 @@ import { test, expect, type Page } from '@playwright/test'; | |
| import fs from 'node:fs'; | ||
| import { authorize, loadFile } from './acts.js'; | ||
|
|
||
| test.use({ | ||
| launchOptions: { | ||
| args: ['--js-flags=--max-old-space-size=512'], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| }, | ||
| }); | ||
|
Comment on lines
+5
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
fd -t f 'playwright.config' web-app/tests
fd -t f 'playwright.config' web-app/tests --exec cat {}Repository: opentdf/web-sdk Length of output: 2796 🏁 Script executed: cat -n web-app/tests/tests/huge.spec.ts | head -50Repository: opentdf/web-sdk Length of output: 1946 🏁 Script executed: wc -l web-app/tests/tests/huge.spec.tsRepository: opentdf/web-sdk Length of output: 94 🏁 Script executed: cat -n web-app/tests/tests/huge.spec.tsRepository: opentdf/web-sdk Length of output: 2207 The heap cap applies only to Chromium; Firefox and WebKit will ignore The Playwright config runs Limit this test to the chromium project, either by wrapping the test.use() call with a project-specific filter or by modifying the Playwright config to exclude firefox/webkit for huge.spec.ts. 🤖 Prompt for AI Agents |
||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| page.on('pageerror', (err) => { | ||
| console.error(err); | ||
|
|
@@ -13,7 +19,10 @@ test.beforeEach(async ({ page }) => { | |
|
|
||
| test('Large File', async ({ page }) => { | ||
| await authorize(page); | ||
| await page.goto(`${appUrl}?segmentBatchSize=2&maxConcurrentSegmentBatches=1`); | ||
| const currentUrl = new URL(page.url()); | ||
| currentUrl.searchParams.set('segmentBatchSize', '2'); | ||
| currentUrl.searchParams.set('maxConcurrentSegmentBatches', '1'); | ||
| await page.goto(currentUrl.toString()); | ||
| await expect(page.locator('#sessionState')).toHaveText('loggedin'); | ||
|
|
||
| const decryptTuningLogs: string[] = []; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,3 +100,60 @@ test('Remote Source Streaming', async ({ page }) => { | |||||||||||||||||
| server.close(); | ||||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| test('Large File', async ({ page }) => { | ||||||||||||||||||
| await authorize(page); | ||||||||||||||||||
| const currentUrl = new URL(page.url()); | ||||||||||||||||||
| currentUrl.searchParams.set('segmentBatchSize', '2'); | ||||||||||||||||||
| currentUrl.searchParams.set('maxConcurrentSegmentBatches', '1'); | ||||||||||||||||||
| await page.goto(currentUrl.toString()); | ||||||||||||||||||
| await expect(page.locator('#sessionState')).toHaveText('loggedin'); | ||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||
|
|
||||||||||||||||||
| const decryptTuningLogs: string[] = []; | ||||||||||||||||||
| page.on('console', (message) => { | ||||||||||||||||||
| const text = message.text(); | ||||||||||||||||||
| if (text.includes('Using decrypt read tuning')) { | ||||||||||||||||||
| decryptTuningLogs.push(text); | ||||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| const threeGigs = 3 * 2 ** 30; | ||||||||||||||||||
| await page.locator('#randomSelector').fill(threeGigs.toString()); | ||||||||||||||||||
|
|
||||||||||||||||||
| const downloadPromise = page.waitForEvent('download'); | ||||||||||||||||||
| await page.locator('#fileSink').click(); | ||||||||||||||||||
| await page.locator('#encryptButton').click(); | ||||||||||||||||||
|
|
||||||||||||||||||
| const download = await downloadPromise; | ||||||||||||||||||
| const cipherTextPath = await download.path(); | ||||||||||||||||||
| try { | ||||||||||||||||||
| expect(download.suggestedFilename()).toContain('bytes'); | ||||||||||||||||||
| expect(cipherTextPath).toBeTruthy(); | ||||||||||||||||||
| if (!cipherTextPath) { | ||||||||||||||||||
| throw new Error(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| await page.locator('#randomSelector').clear(); | ||||||||||||||||||
| await loadFile(page, cipherTextPath); | ||||||||||||||||||
| const plainDownloadPromise = await page.waitForEvent('download', { timeout: 60000 }); | ||||||||||||||||||
| await page.locator('#fileSink').click(); | ||||||||||||||||||
| await page.locator('#decryptButton').click(); | ||||||||||||||||||
| const download2 = await plainDownloadPromise; | ||||||||||||||||||
|
Comment on lines
+138
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Mirror the pattern used on lines 39–42 / 53–56: Proposed fix- const plainDownloadPromise = await page.waitForEvent('download', { timeout: 60000 });
- await page.locator('#fileSink').click();
- await page.locator('#decryptButton').click();
- const download2 = await plainDownloadPromise;
+ const plainDownloadPromise = page.waitForEvent('download', { timeout: 60000 });
+ await page.locator('#fileSink').click();
+ await page.locator('#decryptButton').click();
+ const download2 = await plainDownloadPromise;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| expect(download2.suggestedFilename()).toContain('.decrypted'); | ||||||||||||||||||
| expect(decryptTuningLogs).toEqual([ | ||||||||||||||||||
| 'Using decrypt read tuning {"segmentBatchSize":2,"maxConcurrentSegmentBatches":1}', | ||||||||||||||||||
| ]); | ||||||||||||||||||
| const plainTextPath = await download2.path(); | ||||||||||||||||||
| if (!plainTextPath) { | ||||||||||||||||||
| throw new Error(); | ||||||||||||||||||
| } | ||||||||||||||||||
| try { | ||||||||||||||||||
| const stats = fs.statSync(plainTextPath); | ||||||||||||||||||
| expect(stats).toHaveProperty('size', threeGigs); | ||||||||||||||||||
| } finally { | ||||||||||||||||||
| plainTextPath && fs.unlinkSync(plainTextPath); | ||||||||||||||||||
| } | ||||||||||||||||||
| } finally { | ||||||||||||||||||
| cipherTextPath && fs.unlinkSync(cipherTextPath); | ||||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
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.
PLAYWRIGHT_TESTS_TO_RUNis not consumed bywait-and-test.sh.Per
.github/workflows/roundtrip/wait-and-test.sh(lines 183–198), the script invokesnpm testwith no grep/filter arguments and does not readPLAYWRIGHT_TESTS_TO_RUN. Setting it toroundtrip hugehas no effect on which tests run — Playwright will execute the full suite regardless. Either wire the env var into the script (e.g., forward it as-gor as a positional project/test filter), or drop it here to avoid the false impression of selective targeting.🤖 Prompt for AI Agents