Add comprehensive tests for role middleware and fix package dependencies
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
64aa924270
commit
bfd432d094
1884 changed files with 384668 additions and 84 deletions
81
node_modules/mysql2/lib/tracing.js
generated
vendored
Normal file
81
node_modules/mysql2/lib/tracing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
'use strict';
|
||||
|
||||
const process = require('process');
|
||||
|
||||
// Safe load: use getBuiltinModule if available, fallback to require, catch if unavailable
|
||||
const dc = (() => {
|
||||
try {
|
||||
return 'getBuiltinModule' in process
|
||||
? process.getBuiltinModule('node:diagnostics_channel')
|
||||
: require('node:diagnostics_channel');
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
|
||||
const hasTracingChannel = typeof dc?.tracingChannel === 'function';
|
||||
|
||||
const queryChannel = hasTracingChannel
|
||||
? dc.tracingChannel('mysql2:query')
|
||||
: undefined;
|
||||
|
||||
const executeChannel = hasTracingChannel
|
||||
? dc.tracingChannel('mysql2:execute')
|
||||
: undefined;
|
||||
|
||||
const connectChannel = hasTracingChannel
|
||||
? dc.tracingChannel('mysql2:connect')
|
||||
: undefined;
|
||||
|
||||
const poolConnectChannel = hasTracingChannel
|
||||
? dc.tracingChannel('mysql2:pool:connect')
|
||||
: undefined;
|
||||
|
||||
function getServerContext(config) {
|
||||
if (config.socketPath) {
|
||||
return { serverAddress: config.socketPath, serverPort: undefined };
|
||||
}
|
||||
return {
|
||||
serverAddress: config.host || 'localhost',
|
||||
serverPort: config.port || 3306,
|
||||
};
|
||||
}
|
||||
|
||||
// Node 20+: TracingChannel has an aggregated hasSubscribers getter.
|
||||
// Node 18.x: that getter is missing (undefined), fall back to start sub-channel.
|
||||
function shouldTrace(channel) {
|
||||
if (channel === undefined || channel === null) {
|
||||
return false;
|
||||
}
|
||||
return channel.hasSubscribers ?? channel.start?.hasSubscribers ?? false;
|
||||
}
|
||||
|
||||
// Generic traceCallback wrapper — calls fn synchronously, wraps the callback
|
||||
// at args[position] to emit asyncStart/asyncEnd/error. No promises involved.
|
||||
function traceCallback(channel, fn, position, context, thisArg, ...args) {
|
||||
if (shouldTrace(channel)) {
|
||||
return channel.traceCallback(fn, position, context(), thisArg, ...args);
|
||||
}
|
||||
return fn.apply(thisArg, args);
|
||||
}
|
||||
|
||||
// tracePromise for operations that are inherently async (connection handshake)
|
||||
function tracePromise(channel, fn, contextFactory) {
|
||||
if (shouldTrace(channel)) {
|
||||
return channel.tracePromise(fn, contextFactory());
|
||||
}
|
||||
return fn();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
dc,
|
||||
hasTracingChannel,
|
||||
shouldTrace,
|
||||
queryChannel,
|
||||
executeChannel,
|
||||
connectChannel,
|
||||
poolConnectChannel,
|
||||
getServerContext,
|
||||
traceCallback,
|
||||
tracePromise,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue