Comments (8)
thought about creating a util to yield until the first readable
or error
event, but i'm not sure if it's worth it
from error.
seems we treat these tow kind of errors in different way
from error.
yeah definitely sucks :( I have mixed feelings about adding a root level error handler, it's sort of necessary in this case but then it deviates from the norm, and the fact that you can have multiple error handlers that propagate. streams just don't fit the model really, which is why rails also bypasses middleware when streaming
from error.
i try to hacked ctx.onerror
in koa-onerror, i can not found another way to deal with all errors in one place. but it is really lame.
should we make ctx.onerror
more customizable (e.g. add app.errorHandler=
called by ctx.onerror
), or just let other middlewares to do this lame thing?
from error.
I don't want to form too many opinions based on the current stream implementation since they're super broken. We have a few choices for future stuff I guess, people can stream in the middleware itself, errors would propagate like normal, but it bypasses upstream middleware since you're doing all of the read/write operations in the middleware itself. Or like now with most just assign .body to a stream and let koa do its thing, which then fucks up error handling haha. Both cases kind of suck for different reasons but the latter is probably the most common. I guess what we sort of really need is the ability to prepend middleware, conceptually I don't like that but we have a few other cases for it as well
from error.
i was thinking of doing something like this in either the respond middleware or a error handler. @dead-horse maybe you want to play with this idea?
var stream = this.body
if (stream.pipe) {
yield function (_done) {
stream.read(0)
stream.on('readable', done)
stream.on('error', done)
function done(err) {
stream.removeListener('readable', done)
stream.removeListener('error', done)
_done(err)
}
}
}
it just makes sure the first event isn't an error, which would happen with fs
streams and stuff. maybe listen to the close
event as well - dunno.
only think i can think of is that doing .read(0)
would end empty streams, which i consider a stream bug.
from error.
i want to make sure all errors can caught by my own, so i can decide how to display it. but stream sucks . :(
fortunately in most usage scenarios, streams not necessary. who really want to use it, must understand its disgusting place. maybe we just point this out to let users know haha
from error.
streams not necessary. who really want to use it, must understand its disgusting place.
amen!
from error.
Related Issues (12)
- better default template HOT 4
- Prevent node's default action when emitting "error"
- Swig throws in strict mode HOT 6
- Swig is not currently maintained HOT 5
- Include a better default templating engine HOT 7
- koa-error doesn't depend on the template engine it uses by default HOT 1
- index.js - line 58 - missing comma after 'response: this.response' HOT 1
- Add custom filters and use extend/include the macro/block in view template engine like nunjucks
- using err.expose and NODE_ENV HOT 2
- tests HOT 1
- text/html defaults to text HOT 13
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 error.