Comments (11)
I ran into this same issue. Solved by passing the request parameter {connection: {}}
. E.g.:
app.runMiddleware('/handler', {connection: {}}, function(code, data) {
console.log(code, data);
process.exit();
})
from node-run-middleware.
I solved it by passing original_req
parameter:
app.runMiddleware('/another-route', {original_req: req}, function(err, data) {
...
});
from node-run-middleware.
Looks like adding any sort of middleware is enough to break it :(
var express = require('express');
var runMiddleware = require('run-middleware');
var app = express();
app.use(function (req, res, next) {
console.log({uri: req.originalUrl, method: req.method, ip: req.ip}, 'Request');
next();
});
app.get('/foo', function (req, res) {
res.json({result: 'OK'});
});
runMiddleware(app);
app.runMiddleware('/foo', function (code, body) {
console.log('CODE:', code);
console.log('BODY:', body);
});
results in
_stream_readable.js:633
if (state.pipesCount === 0)
^
TypeError: Cannot read property 'pipesCount' of undefined
at IncomingMessage.Readable.unpipe (_stream_readable.js:633:12)
at unpipe (/home/borisov/test/node-run-middleware/node_modules/unpipe/index.js:47:12)
at send (/home/borisov/test/node-run-middleware/node_modules/finalhandler/index.js:275:3)
at Immediate.<anonymous> (/home/borisov/test/node-run-middleware/node_modules/finalhandler/index.js:135:5)
at Immediate.<anonymous> (/home/borisov/test/node-run-middleware/node_modules/express/lib/router/index.js:635:15)
at runCallback (timers.js:674:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
from node-run-middleware.
Anyone have any idea about what to do if this happens?
from node-run-middleware.
Just ran into this as well.
from node-run-middleware.
I'm getting this error from an entirely different setup that doesn't even include node-run-middleware. So maybe the problem is deeper - like Express itself.
from node-run-middleware.
this still happens if you have routes configured with sendFile:
app.get(CLIENT_ROUTES, function(req, res) {
res.sendFile(join(DIST_FOLDER, 'browser', 'index.html'));
});
I tried every solution proposed above to no avail.
from node-run-middleware.
I solved it by passing
original_req
parameter:app.runMiddleware('/another-route', {original_req: req}, function(err, data) { ... });
this worked for me
from node-run-middleware.
Try to delete the response.json() of the api /sessions , it works for me.
from node-run-middleware.
If anyone wants to create a PR to fix it, I will merge it
from node-run-middleware.
I had this issue before I had a catchall route set up to 404. Basically when a url was accessed where no route matched then this happened. Adding a catchall after all other routes were registered (so it only runs if nothing else matched) fixed it in my case. app.all('*', ...
from node-run-middleware.
Related Issues (20)
- Supports redirect HOT 1
- Add headers objects
- Can this be used with Router? HOT 3
- Small Error in Docs
- async/await usage HOT 2
- ERROR TypeError: Cannot read property 'remoteAddress' of undefined HOT 3
- setting HTTP status during SSR fails HOT 2
- mocking fetch to use node-run-middleware under the hood
- add typescript support
- node-run-middleware and helmet or cors = errors HOT 6
- Add res.json(...) support - /w work around HOT 2
- Buffers / Stream
- .end() Doesn't work HOT 1
- Add an option to call to middleware by using req object HOT 1
- Lack of working res.getHeaders() breaks res.json() and some middleware. Possible fix suggestion. HOT 1
- Pre-population of req.cookies, which is inconsistent with Express, breaks popular "cookie-parse" middleware (PR fix inside)
- Disable the option to add as twice to the same app HOT 1
- Keep the headers and cookies from the current requests HOT 2
- Choose a better name and description HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-run-middleware.