Coder Social home page Coder Social logo

Comments (3)

edspencer avatar edspencer commented on August 22, 2024

Slightly more context: it looks like calling reject() without a reason is supported when the promise is on the client side - see https://react.dev/reference/react/use#dealing-with-rejected-promises

I'm guessing that this may be something to do with how Flight deals with promise resolution.

from next.js.

little077 avatar little077 commented on August 22, 2024

.catch(e=>{
return "no new message found.";
});Maybe you need to throw a catch to catch him

from next.js.

edspencer avatar edspencer commented on August 22, 2024

.catch(e=>{ return "no new message found."; });Maybe you need to throw a catch to catch him

Yes, you can write that code, but it's non-obvious that you need to, and if the Promise that rejects is not in your own codebase then it may be difficult/impossible to do that. Also, it's not going to trigger your error boundary, so now you have 2 code paths to handle errors.

I think this is a bug as it doesn't seem reasonable that rejecting a promise without an argument (which is a valid use of reject()) should crash the process and halt the response. There are workarounds - the catch you mention and also passing an Error instance to reject() (you can even just call reject({digest: 'something'}) as it's the .digest property the code is looking for), but I lost of few hours of my life figuring this out and I can see it affecting others too.

from next.js.

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.