Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/jsc/bindings/BunIDLConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ template<> struct WebCore::Converter<Bun::IDLArrayBufferRef>
if (auto* jsBuffer = JSC::toUnsharedArrayBuffer(vm, value)) {
return jsBuffer;
}
// Also matches DataView: the JSArrayBufferView JSType range ends at DataViewType.
if (auto* jsView = dynamicDowncast<JSC::JSArrayBufferView>(value)) {
return jsView->unsharedBuffer();
}
if (auto* jsDataView = dynamicDowncast<JSC::JSDataView>(value)) {
return jsDataView->unsharedBuffer();
if (jsView->isShared())
return std::nullopt;
if (auto* buf = jsView->unsharedBuffer())
return buf;
return std::nullopt;
}
return std::nullopt;
}
Expand Down
20 changes: 20 additions & 0 deletions test/js/bun/http/bun-serve-ssl.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "fs";
import { bunEnv, bunExe } from "harness";
import tls from "node:tls";
import { join } from "path";
import privateKey from "../../third_party/jsonwebtoken/priv.pem" with { type: "text" };
Expand Down Expand Up @@ -151,6 +152,25 @@ describe("Bun.serve SSL validations", () => {
});
}
}

// Spawned so a regressed RELEASE_ASSERT aborts the child, not this test file.
test.concurrent.each(["Int16Array", "DataView"])(
"SharedArrayBuffer-backed %s as ALPNProtocols does not crash",
async viewType => {
await using proc = Bun.spawn({
cmd: [
bunExe(),
"-e",
`const server = Bun.serve({ port: 0, fetch() { return new Response("ok"); }, ALPNProtocols: new ${viewType}(new SharedArrayBuffer(16)) }); server.stop(true); process.exit(2);`,
],
env: bunEnv,
stderr: "pipe",
});
const [stderr, exitCode] = await Promise.all([proc.stderr.text(), proc.exited]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
expect(stderr).toContain("TypeError");
expect(exitCode).toBe(1);
},
);
});

describe("Bun.serve per-serverName client certificate policy", () => {
Expand Down
Loading