perf: reuse diagnostic bundle byte count (#20292)

Co-authored-by: Orca Worker <orca-worker@localhost>
This commit is contained in:
OrcaWin
2026-09-12 18:08:02 -07:00
committed by GitHub
co-authored by Orca Worker
parent 51ff9c7ff3
commit 64614d73e0
2 changed files with 20 additions and 1 deletions
+19
View File
@@ -58,6 +58,25 @@ describe('bundle — submission ID', () => {
})
describe('bundle — collection', () => {
it.each([
{ kind: 'empty', names: [] },
{ kind: 'ASCII', names: ['plain'] },
{ kind: 'Unicode', names: ['漢字🙂', '\ud800'] },
{ kind: 'capped', names: Array.from({ length: 600 }, () => '漢字🙂'.repeat(1000)) }
])('reports the exact UTF-8 payload size for $kind records', ({ names }) => {
writeFileSync(traceFile, makeNDJSON(names.map((name) => makeSpan({ name }))))
const bundle = collectBundle({
traceFilePath: traceFile,
maxFiles: 1,
appVersion: '1',
platform: 'win32',
arch: 'x64',
osRelease: 'test',
orcaChannel: 'dev'
})
expect(bundle.bytes).toBe(Buffer.byteLength(bundle.payload))
})
it('emits a header line with bundle_submission_id, app_version, platform', () => {
writeFileSync(traceFile, makeNDJSON([makeSpan()]))
const bundle = collectBundle({
+1 -1
View File
@@ -167,7 +167,7 @@ export function collectBundle(opts: CollectBundleOptions): CollectedBundle {
return {
bundleSubmissionId,
payload,
bytes: Buffer.byteLength(payload),
bytes: currentBytes,
spanCount
}
}