fix(config): externalize ws for copilot-m365-web executor (#6130, closes #6062)

Re-lands the #6098 ws-externalization fix onto release/v3.8.44 (it had merged to main by mistake and was reverted). Externalize ws/bufferutil/utf-8-validate so the copilot-m365-web WebSocket masking path works at runtime.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-03 16:42:58 -03:00
committed by GitHub
parent dbc0cdbe1b
commit 1f1fda7cf5
2 changed files with 16 additions and 0 deletions

View File

@@ -214,6 +214,13 @@ const nextConfig = {
"tough-cookie",
"@ngrok/ngrok",
"@huggingface/transformers",
// copilot-m365-web.ts imports 'ws' as a client-side WebSocket. When bundled,
// ws cannot resolve its 'bufferutil' native addon (frame masking) and throws
// TypeError: b.mask is not a function on the first outgoing frame, causing
// every chat request to time out at the stream-readiness watchdog. (#6062)
"ws",
"bufferutil",
"utf-8-validate",
"child_process",
"fs",
"path",

View File

@@ -37,6 +37,15 @@ test("next config exposes standalone build settings and canonical rewrites", asy
"fumadocs-ui",
"fumadocs-core",
]);
// #6062: `ws` and its native masking helpers must stay external so the
// copilot-m365-web executor keeps a working WebSocket masking path at runtime
// (bundling ws breaks `bufferutil` → `TypeError: b.mask is not a function`).
for (const pkg of ["ws", "bufferutil", "utf-8-validate"]) {
assert.ok(
nextConfig.serverExternalPackages.includes(pkg),
`expected serverExternalPackages to externalize "${pkg}" (#6062)`
);
}
assert.equal(headers[0].source, "/:path*");
assert.match(securityHeaders["Content-Security-Policy"], /default-src 'self'/);
assert.match(securityHeaders["Content-Security-Policy"], /frame-ancestors 'none'/);