Git Product home page Git Product logo

Comments (17)

kapraran avatar kapraran commented on June 14, 2024 2

It works without throwing any warning πŸ‘

Thanks for your quick response and this great project!

from legacy.

dalisoft avatar dalisoft commented on June 14, 2024 1

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.

dalisoft avatar dalisoft commented on June 14, 2024

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.

aprilcoskun avatar aprilcoskun commented on June 14, 2024

@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.

dalisoft avatar dalisoft commented on June 14, 2024

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.

dalisoft avatar dalisoft commented on June 14, 2024

@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.

dalisoft avatar dalisoft commented on June 14, 2024

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.

dalisoft avatar dalisoft commented on June 14, 2024

Update docs and i keep this project opened

from legacy.

dalisoft avatar dalisoft commented on June 14, 2024

Related issue here

from legacy.

aprilcoskun avatar aprilcoskun commented on June 14, 2024

@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.

dalisoft avatar dalisoft commented on June 14, 2024

@aprilcoskun Thanks for info, i will research why it happens and if can, i will fix it

from legacy.

Ganuzaz avatar Ganuzaz commented on June 14, 2024

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.

dalisoft avatar dalisoft commented on June 14, 2024

@Ganuzaz Thanks, it is already here https://github.com/dalisoft/nanoexpress/blob/master/src/handler/http.js#L91

from legacy.

Ganuzaz avatar Ganuzaz commented on June 14, 2024

@dalisoft warning still pops out when using sequelize to query.

from legacy.

dalisoft avatar dalisoft commented on June 14, 2024

@Ganuzaz, sorry, I don’t why it is happens, but PR is welcome

from legacy.

dalisoft avatar dalisoft commented on June 14, 2024

This was fixed in PRO version. In Simple/Free version PR is welcome.

from legacy.

dalisoft avatar dalisoft commented on June 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.