-
Notifications
You must be signed in to change notification settings - Fork 3
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
RN/MMM + SES: 20 Promise warnings #13
Comments
nb: from before
a Babel plugin looking most likely (least intrusive/patchy) to switcheroo (transform) back but first the big why polyfill our Android/iOS JSC/V8 global Promise in the first place |
following-up above and we're polyfilling // InitializeJavaScriptAppEngine.js
// ...
function setupPromise() {
// The native Promise implementation throws the following error:
// ERROR: Event loop not supported.
GLOBAL.Promise = require('Promise');
}
// ... still present in // react-native/packages/react-native/Libraries/Core/polyfillPromise.js
// ...
/**
* Set up Promise. The native Promise implementation throws the following error:
* ERROR: Event loop not supported.
*
* If you don't need these polyfills, don't use InitializeCore; just directly
* require the modules you need from InitializeCore for setup.
*/
// ... still the case? after removing our polyfill(s) and testing native
nb: https://test262.report in future // Promise.all() example
const promise1 = Promise.resolve('Resolved value 1');
const promise2 = Promise.resolve('Resolved value 2');
const promise3 = Promise.resolve('Resolved value 3');
(async () => {
try {
const values = await Promise.all([promise1, promise2, promise3]);
console.log(values); // ["Resolved value 1", "Resolved value 2", "Resolved value 3"]
} catch (error) {
console.log(error);
}
})();
// Promise.allSettled() example
const promise4 = Promise.resolve('Resolved value 4');
const promise5 = Promise.reject('Rejected value 5');
(async () => {
try {
const results = await Promise.allSettled([promise4, promise5]);
console.log(results);
// [
// { status: "fulfilled", value: "Resolved value 4" },
// { status: "rejected", reason: "Rejected value 5" }
// ]
} catch (error) {
console.log(error);
}
})();
// Promise.any() example
const promise6 = Promise.reject('Rejected value 6');
const promise7 = Promise.resolve('Resolved value 7');
(async () => {
try {
const value = await Promise.any([promise6, promise7]);
console.log(value); // "Resolved value 7"
} catch (errors) {
console.log(errors);
}
})();
// Promise.prototype.catch() example
const promise8 = Promise.reject('Rejected value 8');
(async () => {
promise8.catch((error) => {
console.log(error); // "Rejected value 8"
});
})();
// Promise.prototype.finally() example
const promise9 = Promise.resolve('Resolved value 9');
(async () => {
try {
const value = await promise9;
console.log(value); // "Resolved value 9"
} catch (error) {
console.log(error);
} finally {
console.log('Promise 9 is settled');
}
})();
// Promise.race() example
const promise10 = new Promise((resolve) => {
setTimeout(() => {
resolve('Resolved value 10');
}, 1000);
});
const promise11 = new Promise((resolve) => {
setTimeout(() => {
resolve('Resolved value 11');
}, 500);
});
(async () => {
try {
const value = await Promise.race([promise10, promise11]);
console.log(value); // "Resolved value 11"
} catch (error) {
console.log(error);
}
})();
// Promise.reject() example
const promise12 = Promise.reject(new Error('Rejected value 12'));
(async () => {
promise12.catch((error) => {
console.log(error.message); // "Rejected value 12"
});
})();
// Promise.resolve() example
const promise13 = Promise.resolve('Resolved value 13');
(async () => {
const value = await promise13;
console.log(value); // "Resolved value 13"
})();
// Promise.prototype.then() example
const promise14 = Promise.resolve('Resolved value 14');
(async () => {
const value = await promise14;
console.log(value); // "Resolved value 14"
})(); # iOS JSC/V8, runtime ok (V8 doesnt log TypeError)
LOG [TypeError: Promise.any is not a function. (In 'Promise.any([promise6, promise7])', 'Promise.any' is undefined)]
LOG Rejected value 8
LOG Resolved value 9
LOG Promise 9 is settled
LOG Rejected value 12
LOG Resolved value 13
LOG Resolved value 14
LOG ["Resolved value 1", "Resolved value 2", "Resolved value 3"]
LOG [{"status": "fulfilled", "value": "Resolved value 4"}, {"reason": "Rejected value 5", "status": "rejected"}]
LOG Running "RN665" with {"rootTag":31,"initialProps":{}}
LOG Resolved value 11
# on event e.g. scroll
SES_UNHANDLED_REJECTION: Rejected value 6 nb: yday JSC/V8 throw/console.error'ed and JSC in Metro twice, so smth was cached - now only logging testing in fresh PoC so we're polyfilling all of // node_modules/react-native/Libraries/Promise.js
const Promise = require('promise/setimmediate/es6-extensions');
require('promise/setimmediate/done');
require('promise/setimmediate/finally');
if (__DEV__) {
require('promise/setimmediate/rejection-tracking').enable(
require('./promiseRejectionTrackingOptions').default,
);
}
module.exports = Promise; i.e. overwriting 8 native to only polyfill i.e. no longer due to the original (8 year old) stale code comment: |
action item PR contributions reflecting above and #5 (comment) opt1
opt2
opt3
until resolved
and
edit: re-check edit: re-check recent changelogs RE Promise.any and Promise.allSettled |
reason 2 for excluding: |
no more warnings with SES baked into RN core (instead of app entry file) in |
Follow-up to
As seen in
Tolerable as we have a fully functioning RN app
These can be ignored via RN's internal LogBox
Or worst-case omit our RN Promise polyfill, then testing meta-maskmobile
Ideal result: Include RN Promise polyfill (or other) with 0 warnings
Not a blocker in RN, unless proves in metamask-mobile (i.e. fuller RN repo's)
First seen in
The text was updated successfully, but these errors were encountered: