Avoiding WebSockets conflicts

An error, Cannot find context with specified id undefined, can be thrown by Puppeteer. According to an issue in the Puppeteer issue queue, this can arise from unplanned interactions between Puppeteer and WebSockets:  https://github.com/GoogleChrome/puppeteer/issues/1325  This issue in turn affects the Socket.IO support in the Notes application, and therefore it may be useful to disable Socket.IO support during test runs.

It's fairly simple to allow disabling of Socket.IO. In app.mjs, add this exported function:

export function enableSocketio() {  var ret = true;  const env = process.env.NOTES_DISABLE_SOCKETIO;  if (!env || env !== 'true') {    ret = true;  }  return ret;}

This looks for an environment variable to cause ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.