Skip to content
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

doc: add timeout.close #40036

Closed
wants to merge 1 commit into from
Closed

doc: add timeout.close #40036

wants to merge 1 commit into from

Conversation

galkin
Copy link
Contributor

@galkin galkin commented Sep 8, 2021

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);
return this;
};

This pull adds documentation for this method.

@nodejs-github-bot nodejs-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
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

Thanks for opening this!

doc/api/timers.md Outdated Show resolved Hide resolved
doc/api/timers.md Show resolved Hide resolved
@tniessen
Copy link
Member

tniessen commented Sep 8, 2021

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

@galkin
Copy link
Contributor Author

galkin commented Sep 8, 2021

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
Copy link
Contributor

aduh95 commented Sep 8, 2021

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
Copy link
Contributor Author

galkin commented Sep 8, 2021

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

doc/api/timers.md Outdated Show resolved Hide resolved
@aduh95 aduh95 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
Contributor Author

galkin commented Sep 13, 2021

@jasnell, could you approve this pull?

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 16, 2021
@github-actions github-actions bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 16, 2021
@github-actions
Copy link
Contributor

Landed in c365145...de10ab2

@github-actions github-actions bot closed this Sep 16, 2021
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>
@BethGriggs BethGriggs mentioned this pull request Sep 21, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants