Git Product home page Git Product logo

Comments (14)

dalisoft avatar dalisoft commented on June 3, 2024

Hi
Thanks for reporting issue.

Issue happening in pro and pro-esm too or only in simple version?

Can you create reproducible repository for quicker progress of solving this issue?

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

I did not perform the tests on others versions, because I liked this version more.

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

There 3 branches on this repository

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

i'm installing via: npm install --save nanoexpress

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

Then it’s simple version. I’ll try to reproduce and fix issue

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

I was doing some tests, and I'm suspecting the "static" module; I made an alternate routine for statistics files that returns with 404, and removed "app.static". and did not give the error.
Then I did another routine to return the file via sendFile, and the error reappeared.

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'error' of undefined
nanoexpress.js:1754:44

if (!result || result.error) {
      if (config._errorHandler) {
        return config._errorHandler(result.error, req, res);
      }
....
}

"!result" = result undefined = undefined.error;

my fix:

return config._errorHandler(result && result.error
          ? result.message
          : 'The route you visited does not returned response', req, res);

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

I solved the problem of "UnhandledPromiseRejectionWarning" by disabling app.static, and creating a routine for it by uploading the file otherwise.
the example is very simple, just for reference.
After this change the error stopped appearing, so I believe it was being created by the "app.static" module;

const fs = require('fs');
const path = require('path');
const mime = require('mime-types');

assetpath = path.resolve(__dirname, 'static');
assetfile = "bundle.min.css";

const getextension = assetfile.split(".");
const contenttype = mime.contentType(getextension[(getextension.length -1)]);

return Promise.all([fs.readFileSync(path.join(assetpath, assetfile))]).then(r => {
                if((r) && (r[0])) {
                    res.status(200);
                    res.setHeader('Content-Type', contenttype);
                    return res.end(r[0]);
                }
                throw new Error("Error: read file");
            }).catch(err => {
                throw new Error(err ? err : "Error: read file");
            });

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

Try use nanoexpress-pro or dalisoft/nanoexpress#pro-esm (ESM only, Node.js 13+). If it's appearing on these branches, then i will fix only master, else i should fix all branches

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

I did not test esm, but I tested pro, and also the error happened when activating "static";
so I believe you should correct the "static" module of all branches to avoid this promise error.

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

On simple version i'm didn't get any errors, but on pro version fixed this error. Maybe you can create reproducible gist or repo?

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

@jamilservicos Can you test new pro and simple version again?

from legacy.

jamilservicos avatar jamilservicos commented on June 3, 2024

I'm kind of out of time, so once I have some time I'll take the test

from legacy.

dalisoft avatar dalisoft commented on June 3, 2024

Issue was closed due of inactivity

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.