Crash with fallback GET route
See original GitHub issueIf you run the following test app:
var express = require('express');
var app = express();
require('express-ws')(app);
app.ws('/test', function(ws, req) {
console.log('incoming connection');
});
app.get('/*', function(req, res, next){
res.sendFile(__dirname + '/test.html');
});
app.listen(3000);
When you make a WebSocket request to ws://localhost:3000/invalidroute, the process crashes with the following exception:
http_outgoing.js:135
this.outputSize += this._header.length;
^
TypeError: Cannot read property 'length' of null
at ServerResponse.OutgoingMessage._send (_http_outgoing.js:135:38)
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:477:16)
at ReadStream.ondata (_stream_readable.js:536:20)
at emitOne (events.js:90:13)
at ReadStream.emit (events.js:182:7)
at readableAddChunk (_stream_readable.js:153:18)
at ReadStream.Readable.push (_stream_readable.js:111:10)
at onread (fs.js:1818:12)
at FSReqWrap.wrapper [as oncomplete] (fs.js:614:17)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:15
Top Results From Across the Web
Fallback rewrites with catch all route causes a JSON error
The application "follows" rewrites when fetching the JSON content (or doesn't fetch it at all) and doesn't crash. To Reproduce. Clone the repo: ......
Read more >react-router dynamic segments crash when accessed
You have two URLs: /settings and /settings/account . In that case, if you have your script inclusion in the fallback file being something...
Read more >Fixing the 'cannot GET /URL' error on refresh with React ...
There are two main ideas for solving this problem. The first, set up both client and server side routing. The second, redirect all...
Read more >How to Use Fallback Routes | Full Laravel 9 Course - YouTube
This video will show you how you could easily setup a fallback route to avoid 404 pages – Want to learn the most...
Read more >Hystrix fallback with Zuul and Spring Boot
To set up the route that will handle this fallback you need to implement the getRoute method. If you want to capture all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there any workaround on this?
I’m working on a project that has a middleware to catch all paths that don’t match any route and return an HTML file.
To overcome the problem described in this issue, we added a check in the middleware to skip its action if the request contains the WebSocket header: