Middleware error not catches
See original GitHub issueI might be making a mistake, but I cannot manage to catch middleware error on client, here is server code:
(function () {
'use strict';
var url = require("url"),
sio = require('socket.io')(3010);
//Authentification required
sio.use(function (socket, next) {
return next(new Error('refused client'));
});
}());
and client code:
(function () {
"use strict";
//Network
var socket = io.connect(SOCKET_IO_SERVER);
socket.on('error', function(){
console.error(arguments);
});
}());
So is it a bug ?
EDIT: Using network tab on chrome I do see a polling
request containing “refused client”
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Exception handler middleware not catching - Stack Overflow
My solution to this problem was to remove app.UseDeveloperExceptionPage(); in Startup.cs.
Read more >Error handling - Express.js
It's important to ensure that Express catches all errors that occur while running route handlers and middleware. Errors that occur in synchronous code ......
Read more >Handle errors in ASP.NET Core | Microsoft Learn
The status code pages middleware does not catch exceptions. To provide a custom error handling page, use the exception handler page.
Read more >A Guide to Error Handling in Express.js | Scout APM Blog
Note: Express 5.0 (currently in alpha) can automatically catch errors (and rejections) thrown by returned Promises. Handling Custom Errors.
Read more >Error Handling in Express - Reflectoring
We are intercepting the error in a catch block and returning an error message with an error code of 500 in the HTTP...
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
I have the same issue when using namespaces. @oliveiragabriel07 solution worked for me as well but I think the client should be able to receive an error thrown in the general connection middelware ( io.use ) I guess this is a socket.io server issue
+1 Error callback is not beeing called on client side when Error is passed as parameter to next on middleware.
Edit
I found that when using namespaces, the middleware should be attached to the namespace: