fix(core): Ensure correct ArrayBuffer return, fix fetch body typing, reorganize node-only tests, and bump tsbuild devDependency

This commit is contained in:
2025-11-16 21:55:40 +00:00
parent 6d148bb59e
commit 9d29bd92da
9 changed files with 995 additions and 621 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartrequest',
version: '4.3.7',
version: '4.3.8',
description: 'A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.'
}

View File

@@ -71,7 +71,7 @@ export class CoreRequest extends AbstractCoreRequest<
// Check for Buffer (Node.js polyfills in browser may provide this)
(typeof Buffer !== 'undefined' && this.options.requestBody instanceof Buffer)
) {
fetchOptions.body = this.options.requestBody;
fetchOptions.body = this.options.requestBody as BodyInit;
// If streaming, we need to set duplex mode
if (this.options.requestBody instanceof ReadableStream) {

View File

@@ -115,10 +115,12 @@ export class CoreResponse<T = any>
*/
async arrayBuffer(): Promise<ArrayBuffer> {
const buffer = await this.collectBody();
return buffer.buffer.slice(
const sliced = buffer.buffer.slice(
buffer.byteOffset,
buffer.byteOffset + buffer.byteLength,
);
// Ensure we return ArrayBuffer, not SharedArrayBuffer
return sliced instanceof ArrayBuffer ? sliced : new ArrayBuffer(0);
}
/**