Comments (17)
It works without throwing any warning π
Thanks for your quick response and this great project!
from legacy.
Thank you to reporting.
These issues appears lack of documentation and i will try to fix these issues and documentation when can find time.
from legacy.
Hi @nikosk93
What result do you get if change some lines?
const path = require('path')
const fs = require('fs')
const nanoexpress = require('nanoexpress')
const util = require('util')
const fsReadDir = util.promisify(fs.readdir)
const app = nanoexpress()
const port = 4000
// list the files of `storage/media` directory
- app.get('/', async (req, res) => {
+ app.get('/', async () => {
let files = []
try {
files = await fsReadDir(path.resolve(__dirname, '../../storage/media'))
- return res.send({error: false, files})
+ return { error: false, files }
} catch (err) {
- return res.send({ error: true })
+ return { error: true }
}
})
// start server
;(async () => {
try {
await app.listen(port, '0.0.0.0')
} catch (err) {
console.error(err)
}
})()
Also, i am added new example of your case.
For me, these changes fixed issue and works good.
Thanks for reporting.
Waiting feedback from you!
Have a nice day!
from legacy.
@dalisoft I got same issue with following code. I was trying middlewares. It's actually works when I test on browser but when I try to benchmark it with "wrk", it's throw this error.
const nanoexpress = require('nanoexpress');
function one(req, res, next) {
req.one = true;
next();
}
function two(req, res, next) {
req.two = true;
next();
}
nanoexpress()
.use(one, two)
.get('/favicon.ico', _ => {})
.get('/', (req, res) => res.send('Hello'))
.get('/user/:id', (req, res) => {
res.end(`User: ${req.params.id}`);
})
.listen(3000);
from legacy.
Hi @aprilcoskun and thanks for interesting and using this library.
This may be due of my cache mechanism or maybe issue relates to uWS and I donβt know exactly what happened currently, but i am will try to debug tomorrow, today cannot because of i am out of computer.
I tomorrow test, inspect and if possible i will fix this, if cannot, will add to docs about this bug.
Thanks for reporting, this helps this library improve quality and reduce bugs
from legacy.
@aprilcoskun
You can try now current changes as workaround
const nanoexpress = require('nanoexpress');
function one(req, res, next) {
req.one = true;
next();
}
function two(req, res, next) {
req.two = true;
next();
}
nanoexpress()
.use(one, two)
- .get('/favicon.ico', _ => {})
+ .get('/favicon.ico', async () => {})
- .get('/', (req, res) => res.send('Hello'))
+ .get('/', (req, res) => res.end('Hello'))
.get('/user/:id', (req, res) => {
res.end(`User: ${req.params.id}`);
})
.listen(3000);
from legacy.
There even says error like this
UnhandledPromiseRejectionWarning: Invalid access of discarded (invalid, deleted) uWS.HttpResponse/SSLHttpResponse
, response is responding/returning, but error does not disappearing, but i tried and seems cannot fix this issue, but i will add this to documentation as Known Issues
from legacy.
Update docs and i keep this project opened
from legacy.
Related issue here
from legacy.
@dalisoft I realized this caused when I try to reach req.params
. Works fine when I don't call request object, It's looks like request object got deleted somewhere.
from legacy.
@aprilcoskun Thanks for info, i will research why it happens and if can, i will fix it
from legacy.
I added res.onAborted before res.send/res.end and the warnings gone
the problem is because the uWebSocket
"Every HttpResponse MUST have an attached abort handler IF you do not respond to it immediately inside of the callback. Returning from an Http request handler without attaching (by calling onAborted) an abort handler is ill-use and will termiante. When this event emits, the response has been aborted and may not be used."
https://unetworking.github.io/uWebSockets.js/generated/interfaces/httpresponse.html#onaborted
the same problem from uWebSockets github uNetworking/uWebSockets.js#123
from legacy.
@Ganuzaz Thanks, it is already here https://github.com/dalisoft/nanoexpress/blob/master/src/handler/http.js#L91
from legacy.
@dalisoft warning still pops out when using sequelize to query.
from legacy.
@Ganuzaz, sorry, I donβt why it is happens, but PR is welcome
from legacy.
This was fixed in PRO version. In Simple/Free version PR is welcome.
from legacy.
@nikosk93 This issue was fixed in v1.1.1
for Simple version.
Sorry for late delay and thanks for your patience!
from legacy.
Related Issues (20)
- Using socket.io + nanoexpress on the same port? HOT 1
- 404 error sometimes HOT 1
- ws handler will parse invalid JSON strings without a try catch block causing server to crash on malformed inputs HOT 1
- UnhandledPromiseRejectionWarning and app.setValidationErrorHandler() HOT 4
- Warning! PRO and PRO (ESM) version will be moved to Private repository HOT 1
- Is handlebars supported in nanoexpress like expressjs? HOT 4
- User forum HOT 4
- JSON body HOT 4
- Enable CORS HOT 5
- Method signature inconsistency - setNotFoundHandler HOT 3
- How to log everything HOT 7
- Options method does not return any data HOT 9
- How to use subscribe publish HOT 2
- websocket parameter wrong interface HOT 4
- Not found handler not activated HOT 5
- [Bug] Throw in async routes doesnt work HOT 4
- Question: No CommonJS for the simple version? HOT 6
- nanoexpress CJS - End of Life date
- Problems when using the examples that include an schema as a middleware HOT 1
- Websocket App publish crashes HOT 15
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 legacy.