Skip to content

Commit 11d346f

Browse files
Stephen Belangernodejs-github-bot
authored andcommitted
doc: deprecate diagnostics_channel object subscribe method
PR-URL: #42714 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
1 parent e9b6d32 commit 11d346f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

doc/api/deprecations.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,24 @@ parameter in [`fs.write()`][], [`fs.writeFile()`][], [`fs.appendFile()`][],
31453145
[`fs.writeFileSync()`][], and [`fs.appendFileSync()`][] is deprecated.
31463146
Convert them to primitive strings.
31473147

3148+
### DEP0163: `channel.subscribe(onMessage)`, `channel.unsubscribe(onMessage)`
3149+
3150+
<!-- YAML
3151+
changes:
3152+
- version: REPLACEME
3153+
pr-url: https://github.com/nodejs/node/pull/42714
3154+
description: Documentation-only deprecation.
3155+
-->
3156+
3157+
Type: Documentation-only
3158+
3159+
These methods were deprecated because they can be used in a way which does not
3160+
hold the channel reference alive long enough to receive the events.
3161+
3162+
Use [`diagnostics_channel.subscribe(name, onMessage)`][] or
3163+
[`diagnostics_channel.unsubscribe(name, onMessage)`][] which does the same
3164+
thing instead.
3165+
31483166
[Legacy URL API]: url.md#legacy-url-api
31493167
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
31503168
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -3185,6 +3203,8 @@ Convert them to primitive strings.
31853203
[`crypto.scrypt()`]: crypto.md#cryptoscryptpassword-salt-keylen-options-callback
31863204
[`decipher.final()`]: crypto.md#decipherfinaloutputencoding
31873205
[`decipher.setAuthTag()`]: crypto.md#deciphersetauthtagbuffer-encoding
3206+
[`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage
3207+
[`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
31883208
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
31893209
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
31903210
[`domain`]: domain.md

doc/api/diagnostics_channel.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ channel.publish({
308308
added:
309309
- v15.1.0
310310
- v14.17.0
311+
deprecated: REPLACEME
311312
-->
312313

314+
> Stability: 0 - Deprecated: Use [`diagnostics_channel.subscribe(name, onMessage)`][]
315+
313316
* `onMessage` {Function} The handler to receive channel messages
314317
* `message` {any} The message data
315318
* `name` {string|symbol} The name of the channel
@@ -344,6 +347,7 @@ channel.subscribe((message, name) => {
344347
added:
345348
- v15.1.0
346349
- v14.17.0
350+
deprecated: REPLACEME
347351
changes:
348352
- version:
349353
- v17.1.0
@@ -353,6 +357,8 @@ changes:
353357
description: Added return value. Added to channels without subscribers.
354358
-->
355359

360+
> Stability: 0 - Deprecated: Use [`diagnostics_channel.unsubscribe(name, onMessage)`][]
361+
356362
* `onMessage` {Function} The previous subscribed handler to remove
357363
* Returns: {boolean} `true` if the handler was found, `false` otherwise.
358364

@@ -424,5 +430,6 @@ Emitted when server sends a response.
424430

425431
[`'uncaughtException'`]: process.md#event-uncaughtexception
426432
[`channel.subscribe(onMessage)`]: #channelsubscribeonmessage
427-
[`diagnostics_channel.subscribe(name, onMessage)`]: #diagnostics_channelunsubscribename_onmessage
428433
[`diagnostics_channel.channel(name)`]: #diagnostics_channelchannelname
434+
[`diagnostics_channel.subscribe(name, onMessage)`]: #diagnostics_channelsubscribename-onmessage
435+
[`diagnostics_channel.unsubscribe(name, onMessage)`]: #diagnostics_channelunsubscribename-onmessage

0 commit comments

Comments
 (0)