GithubHelp home page GithubHelp logo

Comments (25)

lacker avatar lacker commented on July 20, 2024

I think the A+ error behavior is just better. So I support this migration

from parse-sdk-js.

TylerBrock avatar TylerBrock commented on July 20, 2024

Agreed. It was surprising to discover that the Parse JS SDK provides a promise implementation that does not behave the same way as virtually all other promise implementations for Javascript. Perhaps mentioning that the current version is not A+ compliant in the JS Guide someplace would be helpful.

from parse-sdk-js.

weiway avatar weiway commented on July 20, 2024

@TylerBrock Agreed!

from parse-sdk-js.

RaitoBezarius avatar RaitoBezarius commented on July 20, 2024

Is the isAPlusCompliant flag exposed on the latest version of Parse JS SDK?
I am surprised to see only those keys:
["when","is","isPromisesAPlusCompliant","error","arguments","_continueWhile","as","name","caller","prototype","length"]
Whereas, the 1.6.9 seems to include the method to change them, any update on this?

I could give some help on that, because I am using async/await in my code, and it is really a pain to use wrap Parse.Promise each time.

from parse-sdk-js.

andrewimm avatar andrewimm commented on July 20, 2024

@RaitoBezarius I'm not sure I understand the question. The value of the flag can be retrieved by calling Parse.Promise.isPromisesAPlusCompliant(), and the flag can be modified by Parse.Promise.enableAPlusCompliant() / Parse.Promise.enableAPlusCompliant(). The raw boolean controlling all this is made private.

from parse-sdk-js.

RaitoBezarius avatar RaitoBezarius commented on July 20, 2024

@andrewimm When you do Parse.Promise.enableAPlusCompliant() in a Cloud Code function, it will fails because the Cloud Code's Parse JS SDK does not have this method.

from parse-sdk-js.

andrewimm avatar andrewimm commented on July 20, 2024

1.6.9 has not been deployed to cloud code yet. It should be up shortly.

from parse-sdk-js.

RaitoBezarius avatar RaitoBezarius commented on July 20, 2024

@andrewimm Do you have a timeframe? Another question while I can, is async / await doable with the Parse.Promise implementation (without A+ compliance), in your opinion? (Of course, it is transpiled to a runtime regenerator with Babel).

from parse-sdk-js.

andrewimm avatar andrewimm commented on July 20, 2024

It should be doable, since I believe Babel's transpile process works with any thenable (but I can sync up with Sebastian to double-check). If it doesn't, we'll make sure it's supported by 1.7.0.
Keep in mind, Parse Promises are A Compliant by default (not A+ Compliant). The only difference between these is how they handle exceptions. A+ catches an exception, A bubbles it up. The A+ compliance flag shouldn't affect anything related to async/await

from parse-sdk-js.

RaitoBezarius avatar RaitoBezarius commented on July 20, 2024

Thanks for those informations, @andrewimm ! I appreciate. :)

from parse-sdk-js.

cfoulston avatar cfoulston commented on July 20, 2024

I vote A+, really needing some exception handling right now

from parse-sdk-js.

lrettig avatar lrettig commented on July 20, 2024

FYI, I noticed that enabling A+ compliance for Parse Promises breaks at least one core piece of code in ParseReact: cf. parse-community/ParseReact#161.

from parse-sdk-js.

JeremyPlease avatar JeremyPlease commented on July 20, 2024

If we back Parse.Promise with native promises, then would we be able to use process.on('unhandledRejection'...?

from parse-sdk-js.

andrewimm avatar andrewimm commented on July 20, 2024

@JeremyPlease if you could guarantee that you clients all use the native promise and not a polyfill, then yes. But for all clients where we still add the custom implementation because Promise is not supported, we're not going to add an intrusive global event, so it may not be the best thing to depend on. As a developer, I find it's much easier to lint against missing handlers than to use a global catch-all.

from parse-sdk-js.

JeremyPlease avatar JeremyPlease commented on July 20, 2024

@andrewimm Thanks for the quick response!
I mostly want to be able to catch unhandledRejection within Parse server (open source) cloud code. So, support within node wouldn't be an issue. I understand that this sdk is shared on browser clients as well.

Linting against missing handlers sounds like a great idea, but I don't see how this would work when returning promises that return and bubble up to a fail/error/catch handler in another file. If you have any suggestions on how linting would work for promises across files, please let me know.

I'll try to take a look at ParsePromise.js to see what kind of effort there would be use native promises when available and polyfill as needed.

from parse-sdk-js.

recrsn avatar recrsn commented on July 20, 2024

What is the status of these?

from parse-sdk-js.

flovilmart avatar flovilmart commented on July 20, 2024

@JeremyPlease any chance you made progress on that? as it'S 2018, perhaps the promise library should be provided by a 3rd party no?

from parse-sdk-js.

JeremyPlease avatar JeremyPlease commented on July 20, 2024

@flovilmart

The Parse JS SDK is built with babel transform runtime which will polyfill Promise. So, we should be able to use Promise without any 3rd party library.

I just made a quick attempt to use native promises. Unfortunately, this breaks all kinds of tests and functionality that rely on ParsePromise resolutions to happen synchronously.

The current ParsePromise implementation executes the promise callbacks immediately. However, native promises will execute the callbacks on "nextTick" (or a similar approach in browsers). So, tests like this one will fail with native promises since it expects the .then callback of the promise to be executed immediately when p.resolve(); is called. It's likely that some actual functionality could be broken beyond just how tests are written.

My recommendation: keep ParsePromise as-is. If there is a big want/need to switch to a native promise implementation I think it should be done as a v2 release.

from parse-sdk-js.

flovilmart avatar flovilmart commented on July 20, 2024

rely on ParsePromise resolutions to happen synchronously.

Thats, unfortunate and I guess it would introcude a lot of changes.

I think it should be done as a v2 release.

That's reasonable and would be very nice!

from parse-sdk-js.

recrsn avatar recrsn commented on July 20, 2024

My recommendation: keep ParsePromise as-is. If there is a big want/need to switch to a native promise implementation I think it should be done as a v2 release.

This is unfortunate.

However, as promises and async/await are slowly becoming ubiquitous, it will be beneficial for all to be standards compliant. I'm not sure how the synchronous resolution goes along the async/await code.

I'm can help out in porting some of the code, if it is decided to go ahead in this direction.

from parse-sdk-js.

flovilmart avatar flovilmart commented on July 20, 2024

@agathver we’re not against refactoring the code to leverage native promises. As it’s been mentioned, many tests will have to be re-written and we can assist anyone wanting to tackle this task :)

from parse-sdk-js.

JeremyPlease avatar JeremyPlease commented on July 20, 2024

Yeah, definitely unfortunate.

It might be good to have ParsePromise subclass Promise (class ParsePromise extends Promise) but babel doesn't support subclassing builtin classes. There are some ways to work around it though.

The biggest challenge will be modifying tests to properly handle asynchronous resolution of promises and then ensuring there isn't anything else in the Parse JS SDK or Parse Server that is unknowingly taking advantage of the current synchronous behavior.

@agathver Please feel free to take a stab at this and post any updates here 😃

from parse-sdk-js.

EPILock avatar EPILock commented on July 20, 2024

Team, is any work in progress on this?

Thanks

from parse-sdk-js.

flovilmart avatar flovilmart commented on July 20, 2024

It seems that it doesn’t really need to be done at that time as no one is rushing for an implementation. Feel free to take a stab at it

from parse-sdk-js.

dplewis avatar dplewis commented on July 20, 2024

Closed via #620

As of 2.0 of this SDK Parse.Promise has been removed.

from parse-sdk-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.