hashicorp / next-remote-watch

Decorated local server for next.js that enables reloads from remote data changes
Mozilla Public License 2.0
353 stars 19 forks source link

Bug: TypeError: Cannot read property 'send' of undefined #14

Closed helloworld closed 3 years ago

helloworld commented 3 years ago

I'm trying to use next-remote-watch alongside next-mdx-remote.

This is the scriptssection in my package.json:

"scripts": {
    "dev": "PORT=3001 next-remote-watch ../content",
    "build": "next build",
    "start": "next start",
},

Startup works completely fine, but when I go save a file in the ../content folder, I get this error:

➜  yarn dev
yarn run v1.22.4
$ PORT=3001 next-remote-watch ../content
event - compiled successfully
> Ready on http://localhost:3001
(node:54847) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
    at FSWatcher.<anonymous> (/Users/sashank/docs/next/node_modules/next-remote-watch/bin/next-remote-watch:47:27)
    at FSWatcher.emit (events.js:315:20)
    at FSWatcher.emitWithAll (/Users/sashank/docs/next/node_modules/chokidar/index.js:534:8)
    at FSWatcher._emit (/Users/sashank/docs/next/node_modules/chokidar/index.js:626:8)
    at FsEventsHandler.handleEvent (/Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:288:14)
    at FsEventsHandler.addOrChange (/Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:238:8)
    at watchCallback (/Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:342:21)
    at filteredListener (/Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:127:7)
    at /Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:152:11
    at Set.forEach (<anonymous>)
    at /Users/sashank/docs/next/node_modules/chokidar/lib/fsevents-handler.js:151:24
(Use `node --trace-warnings ...` to show where the warning was created)
(node:54847) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 8)
(node:54847) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The error is pointing to this line: https://github.com/hashicorp/next-remote-watch/blob/master/bin/next-remote-watch#L47. My guess is that Next.js might have changed their internal API for hot reloading, breaking this package.

Here are my version pins for relevant packages:

    "next": "^10.0.9",
    "next-mdx-remote": "^2.1.3",
    "next-remote-watch": "^0.3.0",