Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Subscription callback is not nulled out when Subscription is unsubscribed #5464

Closed
Labels
bugConfirmed bug
@felixfbecker

Description

@felixfbecker

Bug Report

Current Behavior
When instantiating a Subscription and passing a callback, that callback is saved asthis._unsubscribe of theSubscription object:

(<any>this)._unsubscribe=unsubscribe;

When unsubscribing that Subscription, the function is called, but not nulled out afterwards:

_unsubscribe.call(this);

This means that if it did some manual resource cleanup like closing a MessagePort, that MessagePort still can't be garbage-collected, because the callback, and therefor the Subscription, still holds a reference to it.

This is different from Subscriptions added viaadd(), which are correctly de-referenced:

this._subscriptions=null;

Reproduction

const{ port1}=newMessageChannel()constsubscription=newSubscription(()=>{port1.close()})subscription.unsubscribe()console.log(subscription._unsubscribe)

Expected behavior
After calling the callback,this._unsubscribe should be nulled out so the callback and its references can be garbage-collected. Since a Subscription can only be unsubscribed once, there is no need to keep the reference.

Environment

  • Runtime: All
  • RxJS version: 6.5.5

Possible Solution
Setthis._unsubscribe tonull whenunsubscribe() is called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp