Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] this._contextPromise.finally is not a function in Firefix 47 (not in 48) #16

Closed
rsoesemann opened this issue Feb 9, 2018 · 20 comments
Labels

Comments

@rsoesemann
Copy link

rsoesemann commented Feb 9, 2018

skype_png

@ruslan-kurchenko
Copy link
Owner

@rsoesemann is it working in Chrome/Safari?

@rsoesemann
Copy link
Author

Yes!

@ruslan-kurchenko
Copy link
Owner

Got it. I will watch on that asap. Thank you!

@ruslan-kurchenko
Copy link
Owner

@rsoesemann
I would guess that Firefox is not compatible with Promise.prototype.finally function:
See answer - https://stackoverflow.com/questions/22516959/how-to-determine-if-a-promise-is-supported-by-the-browser
Also, the link to the Firefox releases - https://wiki.mozilla.org/RapidRelease/Calendar
Release date: 2016-01-25
As soon as in the answer on StackOverflow:
Update Nov 14 - 2016: Chrome, Firefox, Safari and IE all now have experimental support for promises in their dev channels. The specification has settled. I would still not rely on the implementation just yet and would use a library but this might change in a few months.

Do you have client that still work on this old version?

@ruslan-kurchenko
Copy link
Owner

Promise.prototype.finally is part of ES2016+. And unfortunatelly it is not compatible with Firefox 47.
screen shot 2018-02-09 at 7 05 26 pm

@rsoesemann
Copy link
Author

Thanks for digging in so deep. Yes we have a customer using this browser but this is enough material to convince him to upgrade. I hope...

@rsoesemann
Copy link
Author

Anychance for us to work around this on customers who stay on a shitty ff version? We use your lib everywhere 😬

@rsoesemann rsoesemann reopened this Feb 10, 2018
@rsoesemann
Copy link
Author

Is this also a problem with standard salesforce promises? If so it should be excluded from salesforce supported browsers. Is it?

@ruslan-kurchenko
Copy link
Owner

I’ll investigate that deeper. Maybe there is a chance to use polyfill. Stay tuned.

@ruslan-kurchenko
Copy link
Owner

@rsoesemann ok, there is available implementation for situation like we have.
https://www.npmjs.com/package/promise.prototype.finally
I’ll try to use that lib, I think.

@rsoesemann
Copy link
Author

That would be a workaround for the FF 47 issue? Good luck.

@ruslan-kurchenko
Copy link
Owner

Yep, that would be a workaround for all browsers that do not support Promise.prototype.finally
I hope to simplify that, cuz this lib has a lot of logic. It may be an overhead for the component

@rsoesemann
Copy link
Author

Otherwise I have to remove lax from the product 😰

@ruslan-kurchenko
Copy link
Owner

I'll try to fix that. In another case, you could avoid of .finally usage. Or use LaxActionBuilder which doesn't rely on Promise API

@rsoesemann
Copy link
Author

When you say I can use LaxActionBuilder does this mean I can use its newly released "finally" as well?

@ruslan-kurchenko
Copy link
Owner

ruslan-kurchenko commented Feb 11, 2018

@rsoesemann exactly!
See .finallyCallback. The is the simple function without any Promise API logic.

/**
* Creates a unified function to be assign as a callback on the aura action.
* @param resolve {Function} the function called if the action is success
* @param reject {Function} the function called if the action is failed
* @returns {Function}
*/
function actionRouter(resolve, reject, finallyCallback) {
return function (response) {
var state = response.getState();
if (state === 'SUCCESS') {
resolve(response.getReturnValue());
} else {
var message = 'Unknown error';
var responseErrors = response.getError();
if (responseErrors && Array.isArray(responseErrors) && responseErrors.length > 0) {
message = responseErrors[0].message;
}
var errorConstructor = state === 'INCOMPLETE' ? errors.IncompleteActionError : errors.ApexActionError;
reject(new errorConstructor(message, responseErrors, response));
}
if (finallyCallback) {
finallyCallback();
}
};
}

@ruslan-kurchenko
Copy link
Owner

ruslan-kurchenko commented Feb 11, 2018

@rsoesemann just released v1.2.2 with Promise.prototype.finally polyfill for non-compatible browsers.
I've tested on the FF47 and that is working fine.
See examples branch with tests: https://github.com/ruslan-kurchenko/sfdc-lax/blob/examples/src/aura/PromiseFinallyComponent/PromiseFinallyComponentController.js

@ruslan-kurchenko
Copy link
Owner

@rsoesemann let me know if something went wrong with this update.

@rsoesemann
Copy link
Author

Thanks a lot. I will test tommorow.

@rsoesemann
Copy link
Author

It worked. You are AWESOME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants