Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/diagnostics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const dc = require('node:diagnostics_channel');

const initialization = dc.channel('express.initialization');
Comment on lines +3 to +5
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The codebase convention for top-level requires in lib/ files is to use var rather than const. This pattern is consistently followed across all other lib/ files (application.js, request.js, response.js, utils.js, view.js, express.js). While const is used in the codebase for destructuring and local variables inside functions, top-level requires should use var for consistency with the rest of the codebase.

Suggested change
const dc = require('node:diagnostics_channel');
const initialization = dc.channel('express.initialization');
var dc = require('node:diagnostics_channel');
var initialization = dc.channel('express.initialization');

Copilot uses AI. Check for mistakes.

module.exports = { initialization };
6 changes: 6 additions & 0 deletions lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var proto = require('./application');
var Router = require('router');
var req = require('./request');
var res = require('./response');
const channels = require('./diagnostics');
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The codebase convention for top-level requires in lib/ files is to use var rather than const. All other module requires in this file (lines 15-21) use var, and this pattern is consistently followed across all other lib/ files (application.js, request.js, response.js, utils.js, view.js). While const is used in the codebase for destructuring and local variables inside functions, top-level requires should use var for consistency.

Suggested change
const channels = require('./diagnostics');
var channels = require('./diagnostics');

Copilot uses AI. Check for mistakes.

/**
* Expose `createApplication()`.
Expand Down Expand Up @@ -52,6 +53,11 @@ function createApplication() {
})

app.init();

if (channels.initialization.hasSubscribers) {
channels.initialization.publish({ app });
}

return app;
}

Expand Down
26 changes: 26 additions & 0 deletions test/diagnostics-channel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict'

const dc = require('node:diagnostics_channel')
const express = require('../')
const assert = require('node:assert')

describe('diagnostics channels', function () {
describe('express.initialization', function () {
it('should publish when app is created', function () {
let msg

dc.subscribe('express.initialization', function handler (data) {
msg = data
dc.unsubscribe('express.initialization', handler)
})

const app = express()
assert.ok(msg, 'express.initialization was not published')
assert.strictEqual(msg.app, app)
})

it('should not throw when there are no subscribers', function () {
assert.ok(express())
})
})
})
Loading