question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket error using alternative server framework

See original GitHub issue

Version

@nuxt/content: 1.3.2 nuxt: 2.12.2

Reproduction Link

https://github.com/mikeburgh/nuxt-hapi-content Created with npx create-nuxt-app -selecting hapi as the server framework -then adding in the @nuxt/content module

Steps to reproduce

Clone repo Run npm run dev Browse to : http://localhost:3000

What is Expected?

No errors in the console

What is actually happening?

Console is showing an error

 ERROR  Cannot read property 'length' of undefined                                                                                                                                                                20:57:36

  at WebSocket.setSocket (node_modules/@nuxt/content/node_modules/ws/lib/websocket.js:165:14)
  at WebSocketServer.completeUpgrade (node_modules/@nuxt/content/node_modules/ws/lib/websocket-server.js:322:8)
  at WebSocketServer.handleUpgrade (node_modules/@nuxt/content/node_modules/ws/lib/websocket-server.js:245:10)
  at WS.handleUpgrade (node_modules/@nuxt/content/lib/ws.js:21:21)
  at WS.serve (node_modules/@nuxt/content/lib/ws.js:17:10)
  at node_modules/@nuxt/content/lib/middleware.js:11:15
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at WebpackBundler.middleware (node_modules/@nuxt/webpack/dist/webpack.js:5410:5) (repeated 1 times)

The error seems to be caused by the serve method in @nuxt/content/lib/ws.js and happens with both Hapi and express frameworks.

serve (req) {
    this.handleUpgrade(req, req.socket, undefined)
  }

Changing the undefined to an empty array solves it, although not sure if head should actually be something ? Happy to send a PR if head just needs to be an empty array ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
Butochnikovcommented, Jul 23, 2020

I have a similar problem

 ERROR  Cannot read property 'toLowerCase' of undefined                   

  at WebSocketServer.handleUpgrade (node_modules/ws/lib/websocket-server.js:192:27)
  at WS.handleUpgrade (node_modules/@nuxt/content/lib/ws.js:21:21)
  at WS.serve (node_modules/@nuxt/content/lib/ws.js:17:10)
  at node_modules/@nuxt/content/lib/middleware.js:12:15
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at WebpackBundler.middleware (node_modules/@nuxt/webpack/dist/webpack.js:5532:5)
5reactions
ToxicMushroomcommented, Jul 24, 2020

I have a similar problem

 ERROR  Cannot read property 'toLowerCase' of undefined                   

  at WebSocketServer.handleUpgrade (node_modules/ws/lib/websocket-server.js:192:27)
  at WS.handleUpgrade (node_modules/@nuxt/content/lib/ws.js:21:21)
  at WS.serve (node_modules/@nuxt/content/lib/ws.js:17:10)
  at node_modules/@nuxt/content/lib/middleware.js:12:15
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at WebpackBundler.middleware (node_modules/@nuxt/webpack/dist/webpack.js:5532:5)

I’m having that issue without an alternative server framework. I’m using nuxt defaults

Read more comments on GitHub >

github_iconTop Results From Across the Web

25. WebSocket Support - Spring
This part of the reference documentation covers Spring Framework's support for WebSocket-style messaging in web applications including use of STOMP as an ...
Read more >
Server-Sent Events: the alternative to WebSockets you should ...
WebSockets are the most used technology for real-time web apps. However, Server Sent Events (SSE) are a simpler alternative that is often ...
Read more >
WebSocket (ASGI Only) — Falcon 3.1.1 documentation
Error Types. Options. Falcon builds upon the ASGI WebSocket Specification to provide a simple, no-nonsense WebSocket server implementation. With support for ...
Read more >
How to send error in websocket? - Sanic Community Discussion
Gets a close event from the server with a code 1011. Ideally, and instead, what would be good is : Connects; Gets an...
Read more >
Using Spring Boot for WebSocket Implementation with STOMP
The most common alternatives are long polling and server-sent events. Let's look at how to implement WebSockets with the Spring Boot framework, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found