Skip to content

fix sveltekit type error in firebase-frameworks - #673

Merged
leoortizz merged 2 commits into
firebase:mainfrom
leoortizz:fix/sveltekit-buffer-bodyinit
Aug 7, 2026
Merged

fix sveltekit type error in firebase-frameworks#673
leoortizz merged 2 commits into
firebase:mainfrom
leoortizz:fix/sveltekit-buffer-bodyinit

Conversation

@leoortizz

@leoortizz leoortizz commented Jul 31, 2026

Copy link
Copy Markdown
Member

tsc fails under Node 24 / latest @types/node because Buffer no longer satisfies the DOM BodyInit type:

src/sveltekit/index.ts(47,5): error TS2322: Type 'Buffer<ArrayBufferLike> | null' is not assignable to type 'BodyInit | null | undefined'.

Wrap request.rawBody as new Uint8Array(...). Valid BodyInit, runtime unchanged (Buffer is a Uint8Array subclass).

Verified: build passes, and POST bodies still round-trip through a real SvelteKit app.

Node 24 / current @types/node no longer lets Buffer satisfy the DOM
BodyInit type, breaking tsc. Wrap rawBody as new Uint8Array(...) at the
Request construction site; runtime behavior is unchanged.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the SvelteKit request handler to wrap the request's raw body in a Uint8Array. The reviewer pointed out that instantiating a new Uint8Array creates an unnecessary memory copy, and suggested casting the existing buffer to Uint8Array instead to improve performance and reduce memory overhead.

Comment thread packages/firebase-frameworks/src/sveltekit/index.ts Outdated
Assert rawBody to Uint8Array<ArrayBuffer> instead of wrapping it in
new Uint8Array, which copied the whole body. Buffer is
ArrayBuffer-backed
at runtime; only its ArrayBufferLike type keeps BodyInit from accepting
it.
@leoortizz
leoortizz merged commit 2e845c8 into firebase:main Aug 7, 2026
17 of 18 checks passed
@leoortizz
leoortizz deleted the fix/sveltekit-buffer-bodyinit branch August 7, 2026 14:46
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.

2 participants