diff --git a/node-tests/test.js b/node-tests/test.js index e7d407fa5d..734cfc0d7e 100644 --- a/node-tests/test.js +++ b/node-tests/test.js @@ -16,7 +16,7 @@ var id = setTimeout(function () { }, 200); of1(0).pipe( - mergeMap1(function () { return of(x); }), + mergeMap1(function (x) { return of(x); }), mergeMap(function () { return from1(Promise.resolve(1)); }) ).subscribe({ next: function (value) { actual.push(value); }, diff --git a/package-lock.json b/package-lock.json index 006662259a..908287f39a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@reactivex/rxjs", - "version": "6.0.0-beta.1", + "version": "6.0.0-beta.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/internal/Subscriber.ts b/src/internal/Subscriber.ts index 92395ad48e..35d60b3d38 100644 --- a/src/internal/Subscriber.ts +++ b/src/internal/Subscriber.ts @@ -70,10 +70,13 @@ export class Subscriber extends Subscription implements Observer { break; } if (typeof destinationOrNext === 'object') { - if (destinationOrNext instanceof Subscriber) { - this.syncErrorThrowable = destinationOrNext.syncErrorThrowable; - this.destination = (> destinationOrNext); - ( this.destination).add(this); + // HACK(benlesh): For situations where Node has multiple copies of rxjs in + // node_modules, we cannot rely on `instanceof` checks + if (isTrustedSubscriber(destinationOrNext)) { + const trustedSubscriber = destinationOrNext[rxSubscriberSymbol]() as Subscriber; + this.syncErrorThrowable = trustedSubscriber.syncErrorThrowable; + this.destination = trustedSubscriber; + trustedSubscriber.add(this); } else { this.syncErrorThrowable = true; this.destination = new SafeSubscriber(this, > destinationOrNext); @@ -299,4 +302,8 @@ class SafeSubscriber extends Subscriber { this._parentSubscriber = null; _parentSubscriber.unsubscribe(); } -} \ No newline at end of file +} + +function isTrustedSubscriber(obj: any) { + return obj instanceof Subscriber || ('syncErrorThrowable' in obj && obj[rxSubscriberSymbol]); +}