Skip to content

doc: add timeout.close - #40036

Closed
galkin wants to merge 1 commit into
nodejs:masterfrom
galkin:master
Closed

doc: add timeout.close#40036
galkin wants to merge 1 commit into
nodejs:masterfrom
galkin:master

Conversation

@galkin

@galkingalkin commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

Hello,

I noticed that the Timeout.close is not documented. We have this method from v0.9.1:

node/lib/timers.js

Lines 274 to 282 in 985e3a2

Timeout.prototype.close=function(){
this._onTimeout=null;
if(this._handle){
this._handle.ontimeout=null;
this._handle.close();
}else{
exports.unenroll(this);
}
};

Current codebase wraps clearTimeout:

node/lib/timers.js

Lines 251 to 254 in c4096a3

Timeout.prototype.close=function(){
clearTimeout(this);
returnthis;
};

This pull adds documentation for this method.

@nodejs-github-botnodejs-github-bot added doc Issues and PRs related to the documentations. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. labels Sep 8, 2021

@aduh95aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this!

Comment threaddoc/api/timers.md Outdated
Comment threaddoc/api/timers.md Outdated
@tniessen

Copy link
Copy Markdown
Member

Does this have any benefit over clearTimeout, which is also available in other JS environments?

@galkin

Copy link
Copy Markdown
ContributorAuthor

Does this have any benefit over clearTimeout, which is also available in other JS environments?

this is a wrapper around clearTimeout. The name doesn't have _, so there are three options remove right now, document as stable or document as legacy and remove later.

@aduh95

aduh95 commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

document as legacy and remove later.

Actually the legacy status is there for features that we likely won't remove ever:

> Stability: 3 - Legacy. The feature is no longer recommended for use. While it
> likely will not be removed, and is still covered by semantic-versioning
> guarantees, use of the feature should be avoided.

According to the collaborator guide, if it's a feature that was exposed and we have good reasons to think it's used out there (in this case we know for sure it is), we should document it as public:

All functionality in the official Node.js documentation is part of the public
API. Any undocumented object, property, method, argument, behavior, or event is
internal. There are exceptions to this rule. Node.js users have come to rely on
some undocumented behaviors. Collaborators treat many of those undocumented
behaviors as public.

Since it's almost an alias, I think the following applies:

Avoid Runtime Deprecations when an alias or a stub/no-op will suffice. An alias
or stub will have lower maintenance costs for end users and Node.js core.

In this case, I personally it should be documented with Legacy status, unless there are use cases where it makes sense to use it over clearTimeout (in which case it should be documented as stable).

@galkin
galkin requested review from aduh95 and jasnellSeptember 8, 2021 17:37
@galkin

Copy link
Copy Markdown
ContributorAuthor

@aduh95, @jasnell, thanks for the explanation. I added Legacy part.

Comment threaddoc/api/timers.md Outdated
@aduh95aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 9, 2021
@galkin

Copy link
Copy Markdown
ContributorAuthor

@jasnell, could you approve this pull?

Comment threaddoc/api/timers.md Outdated
@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 16, 2021
@github-actionsgithub-actionsBot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 16, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Landed in c365145...de10ab2

nodejs-github-bot pushed a commit that referenced this pull request Sep 16, 2021
PR-URL: #40036
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #40036
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
BethGriggs pushed a commit that referenced this pull request Sep 21, 2021
PR-URL: #40036
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@BethGriggsBethGriggs mentioned this pull request Sep 21, 2021
1 task
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.docIssues and PRs related to the documentations.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@galkin@tniessen@aduh95@jasnell@targos@nodejs-github-bot