Comments (15)
Hi @MrBot45
Thanks for trying out nanoexpress and i'm happy to help here to you, but should create minimal reproducible repo to test.
from nanoexpress.
What do you mean?
from nanoexpress.
Im using nanoexpress as a middleware proxy. It have a lot of bugs but I can't find a solution around for this bug. It seems like the internal fails.
from nanoexpress.
Go on this page to get the error: https://bobuxpvp.tk/login
Enter anything, it always throw an error. It work fine with express so im not sure what's the issue.
from nanoexpress.
What do you mean?
Minimal reproducible repository and/or example, read here to test and fix.
Im using nanoexpress as a middleware proxy. It have a lot of bugs but I can't find a solution around for this bug. It seems like the internal fails.
Please create separate issue for every bug, i'll look and fix as i can. Also, please don't use nanoexpress as a middleware, just use as Server framework without other frameworks :)
from nanoexpress.
Go on this page to get the error: https://bobuxpvp.tk/login
Enter anything, it always throw an error. It work fine with express so im not sure what's the issue.
I see, but i need MRE/MRR to test and know where it fails and fix.
from nanoexpress.
Idk how to reproduce the issue.. It's just a reverse proxy..
from nanoexpress.
Idk how to reproduce the issue.. It's just a reverse proxy..
Thanks for describe how you use. Do you using proxy (example) define to use as reverse proxy
?
from nanoexpress.
No. My project has over 2k lines of code it's hard to provide a minimal example. It require extenal database and stuff.
this.app = nanoexpress();
this.app.setErrorHandler((e, r, s) => {
console.log(e.stack);
s.json({error: e.stack});
});
this.app.any('/*', async (req, res) => { // cant use async for no reason so had to make a custom next function because this never return a "next" parameter
this.process(req, res, () => {
this.next(req, res);
});
});
//Method process
proxy(`${await this.getEndPoint(host)}${reqUrl}`, {
proxyErrorHandler: (err, res, next) => {
console.error('Endpoint errored! Status code:', err);
res.status(507).end(this.errorPage.replace('"Origin"', host || 'unknown host'));
}
})(req, res, next);
// Proxy.js
Please fix your write stream they are buggy. I cant get video streaming to work normaly so i had to create my own write stream (see https://bobuxpvp.tk/video2.webm)
let dest = new Stream();
dest.writable = true;
dest.byteLength = 0;
dest.finalSize = 0;
dest.start = Date.now();
dest.chunks = [];
dest.write = (chunk) => {
try {
if(g) clearTimeout(g);
let chunk_ = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
dest.byteLength += chunk_.byteLength;
if(dest.finalSize > 15000000) {
res.write(chunk_);
} else {
dest.chunks.push(chunk_);
}
} catch(e) {
console.log(e);
}
}
dest.end = () => {
console.log('Took ' + (Date.now() - res.startTime) + 'ms', 'Stream end. Bytes:', dest.byteLength, url, dest.finalSize, dest.chunks.length, dest.finalSize > 15000000);
try {
if(dest.finalSize > 15000000) {
res.end('');
} else {
res.end(Buffer.concat(dest.chunks));
}
} catch(e) {
console.log(e);
}
dest.chunks = [];
}
res.onAborted((e) => {
console.log('Aborded', url);
dest.chunks = [];
errored = true;
});
let proxiedReq = http.request(options, (res_) => {
res.cork(() => {
if(errored) return;
// [...]
if(!errored) res_.pipe(dest);
} [...]```
from nanoexpress.
Seems your proxy
function as middleware working wrong.
Crash on POST request.
TypeError: stream.on is not a function
+ at readStream (/root/middleware/node_modules/raw-body/index.js:190:10)
+ at getRawBody (/root/middleware/node_modules/raw-body/index.js:108:12)
+ at read (/root/middleware/node_modules/body-parser/lib/read.js:77:3)
+ at urlencodedParser (/root/middleware/node_modules/body-parser/lib/types/urlencoded.js:116:5)
at /root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1718:17
at new Promise ()
at middleware (/root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1717:22)
at handler (/root/middleware/node_modules/nanoexpress-pro/cjs/nanoexpress.js:1910:40)
Before nanoexpress these modules are crashing, so checkout proxy define to make proxy easier and high-performant.
Thanks
from nanoexpress.
Will check it out, can you try to fix the write stream? I have to make a check for the buffer size to see if it's smaller than 15mb or it's just abording everytime. Even with this bypass, it's flooding the logs with
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse.
Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse
from nanoexpress.
The stream end itself while writing data.
from nanoexpress.
@MrBot45
Then you using async
or stream
wrong.
As issue creation requires
If this issue not related to this project and exists on core of this project, please close issue or not open
core of this project does not handle these wraps, but nanoexpress does, but it does not mean it does all magic like express, that's why expressjs almost 8x slower than nanoexpress.
My library isn't great, but you should first checkout examples folder as available some examples how do something correctly.
As it's your code issue, i should close issue and then continue in closed status.
If you need premium contact support to fix this, then contact to me via [email protected] or at Telegram
from nanoexpress.
Is it possible to add a next function to setErrorHandler? I want to continue the request even if it get errored. Like express : app.use((err, req, res, next) => {
from nanoexpress.
Yep, it is possible. But always you can use 3 argument, not 4. Check examples and documentations please
from nanoexpress.
Related Issues (20)
- More of the framework needs type declarations HOT 3
- Needs a better structure HOT 4
- "bug" in the loose sense of the word: the FAQ link in the README.md is the wrong link HOT 2
- NanoExpress can't write remove headers HOT 12
- Is a nice pice of code but you can't sell it HOT 1
- Response and request .pipe() method seem bugged HOT 3
- issue with nanoexpress in middleware HOT 1
- Allow getting IP address of machine accessing the server HOT 2
- req.body is undefined if request has large body HOT 6
- Getting Buffer in request.body HOT 1
- can I use express middlewares in nanoexpress for example helmet ? HOT 1
- Cut a new release with uwebsockets.js dependency HOT 6
- Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse. HOT 3
- bug route HOT 3
- v5.2.3 includes "semantic-release" in dependencies HOT 3
- The automated release is failing 🚨 HOT 2
- The automated release is failing 🚨
- The automated release is failing 🚨
- Invalid access of discarded HOT 2
- Nginx Error NanoExpress Server HOT 1
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 nanoexpress.