Comments (14)
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.
I did not perform the tests on others versions, because I liked this version more.
from legacy.
There 3 branches on this repository
from legacy.
i'm installing via: npm install --save nanoexpress
from legacy.
Then it’s simple version. I’ll try to reproduce and fix issue
from legacy.
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.
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.
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.
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.
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.
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.
@jamilservicos Can you test new pro
and simple version again?
from legacy.
I'm kind of out of time, so once I have some time I'll take the test
from legacy.
Issue was closed due of inactivity
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.