Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6e44cab

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(promise): fix #850, check Promise.then writable (#851)
1 parent 5900d3a commit 6e44cab

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/common/promise.ts

+7
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
330330
// Keep a reference to the original method.
331331
proto[symbolThen] = originalThen;
332332

333+
// check Ctor.prototype.then propertyDescritor is writable or not
334+
// in meteor env, writable is false, we have to make it to be true.
335+
const prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then');
336+
if (prop && prop.writable === false && prop.configurable) {
337+
Object.defineProperty(Ctor.prototype, 'then', {writable: true});
338+
}
339+
333340
Ctor.prototype.then = function(onResolve: any, onReject: any) {
334341
const wrapped = new ZoneAwarePromise((resolve, reject) => {
335342
originalThen.call(this, resolve, reject);

0 commit comments

Comments
 (0)