Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
helloworld opened this issue Mar 20, 2021 · 0 comments · Fixed by #15
Closed

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

helloworld opened this issue Mar 20, 2021 · 0 comments · Fixed by #15

Comments

@helloworld
Copy link

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",
lukesmurray added a commit to lukesmurray/next-remote-watch that referenced this issue Mar 24, 2021
Fix hashicorp#14 Cannot read property 'send' of undefined

The internal api for next js changed and placed the hotReloader in a nested server object. Works in next js 10. Not compatible with next js 9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant