Skip to content

Commit 4884f18

Browse files
Stephen Belangertargos
Stephen Belanger
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 3c1ed86 commit 4884f18

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

doc/api/deprecations.md

+20
Original file line numberDiff line numberDiff line change
@@ -3102,6 +3102,24 @@ parameter in [`fs.write()`][], [`fs.writeFile()`][], [`fs.appendFile()`][],
31023102
[`fs.writeFileSync()`][], and [`fs.appendFileSync()`][] is deprecated.
31033103
Convert them to primitive strings.
31043104

3105+
### DEP0163: `channel.subscribe(onMessage)`, `channel.unsubscribe(onMessage)`
3106+
3107+
<!-- YAML
3108+
changes:
3109+
- version: REPLACEME
3110+
pr-url: https://github.com/nodejs/node/pull/42714
3111+
description: Documentation-only deprecation.
3112+
-->
3113+
3114+
Type: Documentation-only
3115+
3116+
These methods were deprecated because they can be used in a way which does not
3117+
hold the channel reference alive long enough to receive the events.
3118+
3119+
Use [`diagnostics_channel.subscribe(name, onMessage)`][] or
3120+
[`diagnostics_channel.unsubscribe(name, onMessage)`][] which does the same
3121+
thing instead.
3122+
31053123
[Legacy URL API]: url.md#legacy-url-api
31063124
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
31073125
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
@@ -3142,6 +3160,8 @@ Convert them to primitive strings.
31423160
[`crypto.scrypt()`]: crypto.md#cryptoscryptpassword-salt-keylen-options-callback
31433161
[`decipher.final()`]: crypto.md#decipherfinaloutputencoding
31443162
[`decipher.setAuthTag()`]: crypto.md#deciphersetauthtagbuffer-encoding
3163+
[`diagnostics_channel.subscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelsubscribename-onmessage
3164+
[`diagnostics_channel.unsubscribe(name, onMessage)`]: diagnostics_channel.md#diagnostics_channelunsubscribename-onmessage
31453165
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
31463166
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
31473167
[`domain`]: domain.md

doc/api/diagnostics_channel.md

+8-1
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,12 +347,15 @@ channel.subscribe((message, name) => {
344347
added:
345348
- v15.1.0
346349
- v14.17.0
350+
deprecated: REPLACEME
347351
changes:
348352
- version: v16.14.0
349353
pr-url: https://github.com/nodejs/node/pull/40433
350354
description: Added return value. Added to channels without subscribers.
351355
-->
352356

357+
> Stability: 0 - Deprecated: Use [`diagnostics_channel.unsubscribe(name, onMessage)`][]
358+
353359
* `onMessage` {Function} The previous subscribed handler to remove
354360
* Returns: {boolean} `true` if the handler was found, `false` otherwise.
355361

@@ -421,5 +427,6 @@ Emitted when server sends a response.
421427

422428
[`'uncaughtException'`]: process.md#event-uncaughtexception
423429
[`channel.subscribe(onMessage)`]: #channelsubscribeonmessage
424-
[`diagnostics_channel.subscribe(name, onMessage)`]: #diagnostics_channelunsubscribename_onmessage
425430
[`diagnostics_channel.channel(name)`]: #diagnostics_channelchannelname
431+
[`diagnostics_channel.subscribe(name, onMessage)`]: #diagnostics_channelsubscribename-onmessage
432+
[`diagnostics_channel.unsubscribe(name, onMessage)`]: #diagnostics_channelunsubscribename-onmessage

0 commit comments

Comments
 (0)