Uncaught (in response) Error with WebsocketPair Example

I am testing a websocket handler built in a Cloudflare worker using the example code here:
https://github.com/cloudflare/websocket-template

When connecting to the example from a browser everything works correctly:

const websocket = new WebSocket('ws://127.0.0.1:8787/ws')

websocket.addEventListener('message', event => {
    console.log(JSON.stringify(event.data));
});

websocket.addEventListener('open', () => {
    websocket.send('CLICK');
});

I see the correct response when sending the “CLICK” message, but when I call websocket.close() from the client, I see this error logged in Cloudflare:

Uncaught (in response) Error: The script will never generate a response.

I get this error for the examples listed on https://developers.cloudflare.com/workers/learning/using-websockets/ as well, even when publishing the code to Cloudflare and connecting to a production endpoint.

I’ve tried tracing the error using wrangler dev --log-level=debug --experimental-local and saw this error:

workerd/server/server.c++:2091: error: Uncaught exception: workerd/io/io-context.c++:1228: failed: remote.jsg.Error: The script will never generate a response.
stack: 10518d190 10518d9d0 10518e210 10775fff0 10753b66b 107740c06 1052dc340 1052dc620 1052dc58c 107740c06 10518e210 1074e9bb0 1074ed030

Is there a way to resolve this error or instruct Cloudflare to ignore it? The error is rather obscure and other occurrences documented online appear unrelated.