@stacks/api-toolkit 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/fastify/cache.d.ts +0 -31
- package/dist/fastify/cache.js +0 -63
- package/dist/fastify/cache.js.map +0 -1
- package/dist/fastify/fastify.d.ts +0 -16
- package/dist/fastify/fastify.js +0 -46
- package/dist/fastify/fastify.js.map +0 -1
- package/dist/fastify/index.d.ts +0 -4
- package/dist/fastify/index.js +0 -21
- package/dist/fastify/index.js.map +0 -1
- package/dist/fastify/openapi.d.ts +0 -13
- package/dist/fastify/openapi.js +0 -23
- package/dist/fastify/openapi.js.map +0 -1
- package/dist/fastify/schemas.d.ts +0 -9
- package/dist/fastify/schemas.js +0 -16
- package/dist/fastify/schemas.js.map +0 -1
- package/dist/helpers/events.d.ts +0 -52
- package/dist/helpers/events.js +0 -93
- package/dist/helpers/events.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -7
- package/dist/helpers/index.js +0 -25
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/is-debugging.d.ts +0 -1
- package/dist/helpers/is-debugging.js +0 -15
- package/dist/helpers/is-debugging.js.map +0 -1
- package/dist/helpers/iterators.d.ts +0 -27
- package/dist/helpers/iterators.js +0 -74
- package/dist/helpers/iterators.js.map +0 -1
- package/dist/helpers/serialize-error.d.ts +0 -20
- package/dist/helpers/serialize-error.js +0 -135
- package/dist/helpers/serialize-error.js.map +0 -1
- package/dist/helpers/time.d.ts +0 -54
- package/dist/helpers/time.js +0 -121
- package/dist/helpers/time.js.map +0 -1
- package/dist/helpers/values.d.ts +0 -68
- package/dist/helpers/values.js +0 -165
- package/dist/helpers/values.js.map +0 -1
- package/dist/helpers/worker-thread-init.d.ts +0 -1
- package/dist/helpers/worker-thread-init.js +0 -67
- package/dist/helpers/worker-thread-init.js.map +0 -1
- package/dist/helpers/worker-thread-manager.d.ts +0 -53
- package/dist/helpers/worker-thread-manager.js +0 -148
- package/dist/helpers/worker-thread-manager.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -24
- package/dist/index.js.map +0 -1
- package/dist/logger/index.d.ts +0 -20
- package/dist/logger/index.js +0 -14
- package/dist/logger/index.js.map +0 -1
- package/dist/postgres/base-pg-store.d.ts +0 -68
- package/dist/postgres/base-pg-store.js +0 -109
- package/dist/postgres/base-pg-store.js.map +0 -1
- package/dist/postgres/connection.d.ts +0 -62
- package/dist/postgres/connection.js +0 -126
- package/dist/postgres/connection.js.map +0 -1
- package/dist/postgres/errors.d.ts +0 -5
- package/dist/postgres/errors.js +0 -71
- package/dist/postgres/errors.js.map +0 -1
- package/dist/postgres/index.d.ts +0 -5
- package/dist/postgres/index.js +0 -22
- package/dist/postgres/index.js.map +0 -1
- package/dist/postgres/migrations.d.ts +0 -47
- package/dist/postgres/migrations.js +0 -134
- package/dist/postgres/migrations.js.map +0 -1
- package/dist/postgres/types.d.ts +0 -14
- package/dist/postgres/types.js +0 -48
- package/dist/postgres/types.js.map +0 -1
- package/dist/profiler/index.d.ts +0 -2
- package/dist/profiler/index.js +0 -19
- package/dist/profiler/index.js.map +0 -1
- package/dist/profiler/inspector-util.d.ts +0 -29
- package/dist/profiler/inspector-util.js +0 -268
- package/dist/profiler/inspector-util.js.map +0 -1
- package/dist/profiler/server.d.ts +0 -6
- package/dist/profiler/server.js +0 -186
- package/dist/profiler/server.js.map +0 -1
- package/dist/server-version/index.d.ts +0 -8
- package/dist/server-version/index.js +0 -33
- package/dist/server-version/index.js.map +0 -1
- package/dist/shutdown-handler/index.d.ts +0 -17
- package/dist/shutdown-handler/index.js +0 -82
- package/dist/shutdown-handler/index.js.map +0 -1
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initCpuProfiling = initCpuProfiling;
|
|
4
|
-
exports.initHeapSnapshot = initHeapSnapshot;
|
|
5
|
-
const inspector = require("inspector");
|
|
6
|
-
const helpers_1 = require("../helpers");
|
|
7
|
-
const logger_1 = require("../logger");
|
|
8
|
-
function isInspectorNotConnectedError(error) {
|
|
9
|
-
const ERR_INSPECTOR_NOT_CONNECTED = 'ERR_INSPECTOR_NOT_CONNECTED';
|
|
10
|
-
const isNodeError = (r) => r instanceof Error && 'code' in r;
|
|
11
|
-
return isNodeError(error) && error.code === ERR_INSPECTOR_NOT_CONNECTED;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Connects and enables a new `inspector` session, then starts an internal v8 CPU profiling process.
|
|
15
|
-
* @returns A function to stop the profiling, and return the CPU profile result object.
|
|
16
|
-
* The result object can be used to create a `.cpuprofile` file using JSON.stringify.
|
|
17
|
-
* Use VSCode or Chrome's 'DevTools for Node' (under chrome://inspect) to visualize the `.cpuprofile` file.
|
|
18
|
-
* @param samplingInterval - Optionally set sampling interval in microseconds, default is 1000 microseconds.
|
|
19
|
-
*/
|
|
20
|
-
function initCpuProfiling(samplingInterval) {
|
|
21
|
-
const sessionStopwatch = (0, helpers_1.stopwatch)();
|
|
22
|
-
const session = new inspector.Session();
|
|
23
|
-
session.connect();
|
|
24
|
-
logger_1.logger.info(`[CpuProfiler] Connect session took ${sessionStopwatch.getElapsedAndRestart()}ms`);
|
|
25
|
-
const start = async () => {
|
|
26
|
-
const sw = (0, helpers_1.stopwatch)();
|
|
27
|
-
logger_1.logger.info(`[CpuProfiler] Enabling profiling...`);
|
|
28
|
-
await new Promise((resolve, reject) => {
|
|
29
|
-
try {
|
|
30
|
-
session.post('Profiler.enable', error => {
|
|
31
|
-
if (error) {
|
|
32
|
-
logger_1.logger.error(error, '[CpuProfiler] Error enabling profiling');
|
|
33
|
-
reject(error);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
logger_1.logger.info(`[CpuProfiler] Profiling enabled`);
|
|
37
|
-
resolve();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
logger_1.logger.error(error, '[CpuProfiler] Error enabling profiling');
|
|
43
|
-
reject(error);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
logger_1.logger.info(`[CpuProfiler] Enable session took ${sw.getElapsedAndRestart()}ms`);
|
|
47
|
-
if (samplingInterval !== undefined) {
|
|
48
|
-
logger_1.logger.info(`[CpuProfiler] Setting sampling interval to ${samplingInterval} microseconds`);
|
|
49
|
-
await new Promise((resolve, reject) => {
|
|
50
|
-
try {
|
|
51
|
-
session.post('Profiler.setSamplingInterval', { interval: samplingInterval }, error => {
|
|
52
|
-
if (error) {
|
|
53
|
-
logger_1.logger.error(error, '[CpuProfiler] Error setting sampling interval');
|
|
54
|
-
reject(error);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
logger_1.logger.info(`[CpuProfiler] Set sampling interval`);
|
|
58
|
-
resolve();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
logger_1.logger.error(error, '[CpuProfiler] Error setting sampling interval');
|
|
64
|
-
reject(error);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
logger_1.logger.info(`[CpuProfiler] Set sampling interval took ${sw.getElapsedAndRestart()}ms`);
|
|
68
|
-
}
|
|
69
|
-
logger_1.logger.info(`[CpuProfiler] Profiling starting...`);
|
|
70
|
-
await new Promise((resolve, reject) => {
|
|
71
|
-
try {
|
|
72
|
-
session.post('Profiler.start', error => {
|
|
73
|
-
if (error) {
|
|
74
|
-
logger_1.logger.error(error, '[CpuProfiler] Error starting profiling');
|
|
75
|
-
reject(error);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
sessionStopwatch.restart();
|
|
79
|
-
logger_1.logger.info(`[CpuProfiler] Profiling started`);
|
|
80
|
-
resolve();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
logger_1.logger.error(error, '[CpuProfiler] Error starting profiling');
|
|
86
|
-
reject(error);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
logger_1.logger.info(`[CpuProfiler] Start profiler took ${sw.getElapsedAndRestart()}ms`);
|
|
90
|
-
};
|
|
91
|
-
const stop = async () => {
|
|
92
|
-
const sw = (0, helpers_1.stopwatch)();
|
|
93
|
-
logger_1.logger.info(`[CpuProfiler] Profiling stopping...`);
|
|
94
|
-
try {
|
|
95
|
-
return await new Promise((resolve, reject) => {
|
|
96
|
-
try {
|
|
97
|
-
session.post('Profiler.stop', (error, profileResult) => {
|
|
98
|
-
if (error) {
|
|
99
|
-
logger_1.logger.error(error, '[CpuProfiler] Error stopping profiling');
|
|
100
|
-
reject(error);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
logger_1.logger.info(`[CpuProfiler] Profiling stopped`);
|
|
104
|
-
resolve(profileResult.profile);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
reject(error);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
logger_1.logger.info(`[CpuProfiler] Stop profiler took ${sw.getElapsedAndRestart()}ms`);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const dispose = async () => {
|
|
118
|
-
const sw = (0, helpers_1.stopwatch)();
|
|
119
|
-
try {
|
|
120
|
-
logger_1.logger.info(`[CpuProfiler] Disabling profiling...`);
|
|
121
|
-
await new Promise((resolve, reject) => {
|
|
122
|
-
try {
|
|
123
|
-
session.post('Profiler.disable', error => {
|
|
124
|
-
if (error && isInspectorNotConnectedError(error)) {
|
|
125
|
-
logger_1.logger.info(`[CpuProfiler] Profiler already disconnected`);
|
|
126
|
-
resolve();
|
|
127
|
-
}
|
|
128
|
-
else if (error) {
|
|
129
|
-
logger_1.logger.error(error, '[CpuProfiler] Error disabling profiling');
|
|
130
|
-
reject(error);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
logger_1.logger.info(`[CpuProfiler] Profiling disabled`);
|
|
134
|
-
resolve();
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
if (isInspectorNotConnectedError(error)) {
|
|
140
|
-
logger_1.logger.info(`[CpuProfiler] Profiler already disconnected`);
|
|
141
|
-
resolve();
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
reject();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
finally {
|
|
150
|
-
session.disconnect();
|
|
151
|
-
logger_1.logger.info(`[CpuProfiler] Disable and disconnect profiler took ${sw.getElapsedAndRestart()}ms`);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
return { start, stop, dispose, session, sessionType: 'cpu', stopwatch: sessionStopwatch };
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Connects and enables a new `inspector` session, then creates an internal v8 Heap profiler snapshot.
|
|
158
|
-
* @param outputStream - An output stream that heap snapshot chunks are written to.
|
|
159
|
-
* The result stream can be used to create a `.heapsnapshot` file.
|
|
160
|
-
* Use Chrome's 'DevTools for Node' (under chrome://inspect) to visualize the `.heapsnapshot` file.
|
|
161
|
-
*/
|
|
162
|
-
function initHeapSnapshot(outputStream) {
|
|
163
|
-
const sw = (0, helpers_1.stopwatch)();
|
|
164
|
-
const session = new inspector.Session();
|
|
165
|
-
session.connect();
|
|
166
|
-
let totalSnapshotByteSize = 0;
|
|
167
|
-
const start = async () => {
|
|
168
|
-
logger_1.logger.info(`[HeapProfiler] Enabling profiling...`);
|
|
169
|
-
await new Promise((resolve, reject) => {
|
|
170
|
-
try {
|
|
171
|
-
session.post('HeapProfiler.enable', error => {
|
|
172
|
-
if (error) {
|
|
173
|
-
logger_1.logger.error(error, '[HeapProfiler] Error enabling profiling');
|
|
174
|
-
reject(error);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
sw.restart();
|
|
178
|
-
logger_1.logger.info(`[HeapProfiler] Profiling enabled`);
|
|
179
|
-
resolve();
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
logger_1.logger.error(error, '[HeapProfiler] Error enabling profiling');
|
|
185
|
-
reject(error);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
session.on('HeapProfiler.addHeapSnapshotChunk', message => {
|
|
189
|
-
// Note: this doesn't handle stream back-pressure, but we don't have control over the
|
|
190
|
-
// `HeapProfiler.addHeapSnapshotChunk` callback in order to use something like piping.
|
|
191
|
-
// So in theory on a slow `outputStream` (usually an http connection response) this can cause OOM.
|
|
192
|
-
logger_1.logger.info(`[HeapProfiler] Writing heap snapshot chunk of size ${message.params.chunk.length}`);
|
|
193
|
-
totalSnapshotByteSize += message.params.chunk.length;
|
|
194
|
-
outputStream.write(message.params.chunk, error => {
|
|
195
|
-
if (error) {
|
|
196
|
-
logger_1.logger.error(error, `[HeapProfiler] Error writing heap profile chunk to output stream: ${error.message}`);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
const stop = async () => {
|
|
202
|
-
logger_1.logger.info(`[HeapProfiler] Taking snapshot...`);
|
|
203
|
-
await new Promise((resolve, reject) => {
|
|
204
|
-
try {
|
|
205
|
-
session.post('HeapProfiler.takeHeapSnapshot', undefined, (error) => {
|
|
206
|
-
if (error) {
|
|
207
|
-
logger_1.logger.error(error, '[HeapProfiler] Error taking snapshot');
|
|
208
|
-
reject(error);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
logger_1.logger.info(`[HeapProfiler] Taking snapshot completed, ${totalSnapshotByteSize} bytes...`);
|
|
212
|
-
resolve();
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
catch (error) {
|
|
217
|
-
logger_1.logger.error(error, '[HeapProfiler] Error taking snapshot');
|
|
218
|
-
reject(error);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
logger_1.logger.info(`[HeapProfiler] Draining snapshot buffer to stream...`);
|
|
222
|
-
const writeFinishedPromise = new Promise((resolve, reject) => {
|
|
223
|
-
outputStream.on('finish', () => resolve());
|
|
224
|
-
outputStream.on('error', error => reject(error));
|
|
225
|
-
});
|
|
226
|
-
outputStream.end();
|
|
227
|
-
await writeFinishedPromise;
|
|
228
|
-
logger_1.logger.info(`[HeapProfiler] Finished draining snapshot buffer to stream`);
|
|
229
|
-
return { totalSnapshotByteSize };
|
|
230
|
-
};
|
|
231
|
-
const dispose = async () => {
|
|
232
|
-
try {
|
|
233
|
-
logger_1.logger.info(`[HeapProfiler] Disabling profiling...`);
|
|
234
|
-
await new Promise((resolve, reject) => {
|
|
235
|
-
try {
|
|
236
|
-
session.post('HeapProfiler.disable', error => {
|
|
237
|
-
if (error && isInspectorNotConnectedError(error)) {
|
|
238
|
-
logger_1.logger.info(`[HeapProfiler] Profiler already disconnected`);
|
|
239
|
-
resolve();
|
|
240
|
-
}
|
|
241
|
-
else if (error) {
|
|
242
|
-
logger_1.logger.error(error, '[HeapProfiler] Error disabling profiling');
|
|
243
|
-
reject(error);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
logger_1.logger.info(`[HeapProfiler] Profiling disabled`);
|
|
247
|
-
resolve();
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
catch (error) {
|
|
252
|
-
if (isInspectorNotConnectedError(error)) {
|
|
253
|
-
logger_1.logger.info(`[HeapProfiler] Profiler already disconnected`);
|
|
254
|
-
resolve();
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
reject();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
finally {
|
|
263
|
-
session.disconnect();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
return { start, stop, dispose, session, sessionType: 'memory', stopwatch: sw };
|
|
267
|
-
}
|
|
268
|
-
//# sourceMappingURL=inspector-util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspector-util.js","sourceRoot":"","sources":["../../src/profiler/inspector-util.ts"],"names":[],"mappings":";;AA6BA,4CAgIC;AAQD,4CA6GC;AAlRD,uCAAuC;AAEvC,wCAAkD;AAClD,sCAAmC;AAanC,SAAS,4BAA4B,CAAC,KAAc;IAClD,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;IAClE,MAAM,WAAW,GAAG,CAAC,CAAU,EAA8B,EAAE,CAAC,CAAC,YAAY,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC;IAClG,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,2BAA2B,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,gBAAyB;IACxD,MAAM,gBAAgB,GAAG,IAAA,mBAAS,GAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,eAAM,CAAC,IAAI,CAAC,sCAAsC,gBAAgB,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAC/F,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACvB,MAAM,EAAE,GAAG,IAAA,mBAAS,GAAE,CAAC;QACvB,eAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACnD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;oBACtC,IAAI,KAAK,EAAE,CAAC;wBACV,eAAM,CAAC,KAAK,CAAC,KAAK,EAAE,wCAAwC,CAAC,CAAC;wBAC9D,MAAM,CAAC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BACZ,CAAC;6BAAM,IAAI,KAAK,EAAE,CAAC;4BACjB,eAAM,CAAC,KAAK,CAAC,KAAK,EAAE,0CAA0C,CAAC,CAAC;4BAChE,MAAM,CAAC,KAAK,CAAC,CAAC;wBAChB,CAAC;6BAAM,CAAC;4BACN,eAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;4BACjD,OAAO,EAAE,CAAC;wBACZ,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;wBACxC,eAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;wBAC5D,OAAO,EAAE,CAAC;oBACZ,CAAC;yBAAM,CAAC;wBACN,MAAM,EAAE,CAAC;oBACX,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AACjF,CAAC"}
|
package/dist/profiler/server.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildProfilerServer = buildProfilerServer;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const helpers_1 = require("../helpers");
|
|
9
|
-
const promises_1 = require("node:stream/promises");
|
|
10
|
-
const logger_1 = require("../logger");
|
|
11
|
-
const fastify_1 = require("fastify");
|
|
12
|
-
const type_provider_typebox_1 = require("@fastify/type-provider-typebox");
|
|
13
|
-
const inspector_util_1 = require("./inspector-util");
|
|
14
|
-
const DurationSchema = type_provider_typebox_1.Type.Number({ minimum: 0 });
|
|
15
|
-
const SamplingIntervalSchema = type_provider_typebox_1.Type.Optional(type_provider_typebox_1.Type.Number({ minimum: 0 }));
|
|
16
|
-
const CpuProfiler = (fastify, options, done) => {
|
|
17
|
-
let existingSession;
|
|
18
|
-
fastify.get('/profile/cpu', {
|
|
19
|
-
schema: {
|
|
20
|
-
querystring: type_provider_typebox_1.Type.Object({
|
|
21
|
-
duration: DurationSchema,
|
|
22
|
-
sampling_interval: SamplingIntervalSchema,
|
|
23
|
-
}),
|
|
24
|
-
},
|
|
25
|
-
}, async (req, res) => {
|
|
26
|
-
if (existingSession) {
|
|
27
|
-
await res.status(409).send({ error: 'Profile session already in progress' });
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const seconds = req.query.duration;
|
|
31
|
-
const samplingInterval = req.query.sampling_interval;
|
|
32
|
-
const cpuProfiler = (0, inspector_util_1.initCpuProfiling)(samplingInterval);
|
|
33
|
-
existingSession = { instance: cpuProfiler, response: res };
|
|
34
|
-
try {
|
|
35
|
-
const filename = `cpu_${Math.round(Date.now() / 1000)}_${seconds}-seconds.cpuprofile`;
|
|
36
|
-
await cpuProfiler.start();
|
|
37
|
-
const ac = new AbortController();
|
|
38
|
-
const timeoutPromise = (0, helpers_1.timeout)(seconds * 1000, ac);
|
|
39
|
-
await Promise.race([timeoutPromise, (0, events_1.once)(res.raw, 'close')]);
|
|
40
|
-
if (res.raw.writableEnded || res.raw.destroyed) {
|
|
41
|
-
// session was cancelled
|
|
42
|
-
ac.abort();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const result = await cpuProfiler.stop();
|
|
46
|
-
const resultString = JSON.stringify(result);
|
|
47
|
-
logger_1.logger.info(`[CpuProfiler] Completed, total profile report JSON string length: ${resultString.length}`);
|
|
48
|
-
await res
|
|
49
|
-
.headers({
|
|
50
|
-
'Cache-Control': 'no-store',
|
|
51
|
-
'Transfer-Encoding': 'chunked',
|
|
52
|
-
'Content-Disposition': `attachment; filename="${filename}"`,
|
|
53
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
54
|
-
})
|
|
55
|
-
.send(resultString);
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
const session = existingSession;
|
|
59
|
-
existingSession = undefined;
|
|
60
|
-
await session?.instance.dispose().catch();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
fastify.get('/profile/cpu/start', {
|
|
64
|
-
schema: {
|
|
65
|
-
querystring: type_provider_typebox_1.Type.Object({
|
|
66
|
-
sampling_interval: SamplingIntervalSchema,
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
|
-
}, async (req, res) => {
|
|
70
|
-
if (existingSession) {
|
|
71
|
-
await res.status(409).send({ error: 'Profile session already in progress' });
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const samplingInterval = req.query.sampling_interval;
|
|
75
|
-
const cpuProfiler = (0, inspector_util_1.initCpuProfiling)(samplingInterval);
|
|
76
|
-
existingSession = { instance: cpuProfiler, response: res };
|
|
77
|
-
await cpuProfiler.start();
|
|
78
|
-
const profilerRunningLogger = setInterval(() => {
|
|
79
|
-
if (existingSession) {
|
|
80
|
-
logger_1.logger.error(`CPU profiler has been enabled for a long time`);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
clearInterval(profilerRunningLogger);
|
|
84
|
-
}
|
|
85
|
-
}, 10_000).unref();
|
|
86
|
-
await res.send('CPU profiler started');
|
|
87
|
-
});
|
|
88
|
-
fastify.get('/profile/cpu/stop', async (req, res) => {
|
|
89
|
-
if (!existingSession) {
|
|
90
|
-
await res.status(409).send({ error: 'No profile session in progress' });
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (existingSession.instance.sessionType !== 'cpu') {
|
|
94
|
-
await res.status(409).send({ error: 'No CPU profile session in progress' });
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
try {
|
|
98
|
-
const elapsedSeconds = existingSession.instance.stopwatch.getElapsedSeconds();
|
|
99
|
-
const timestampSeconds = Math.round(Date.now() / 1000);
|
|
100
|
-
const filename = `cpu_${timestampSeconds}_${elapsedSeconds}-seconds.cpuprofile`;
|
|
101
|
-
const result = await existingSession.instance.stop();
|
|
102
|
-
const resultString = JSON.stringify(result);
|
|
103
|
-
logger_1.logger.info(`[CpuProfiler] Completed, total profile report JSON string length: ${resultString.length}`);
|
|
104
|
-
await res
|
|
105
|
-
.headers({
|
|
106
|
-
'Cache-Control': 'no-store',
|
|
107
|
-
'Transfer-Encoding': 'chunked',
|
|
108
|
-
'Content-Disposition': `attachment; filename="${filename}"`,
|
|
109
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
110
|
-
})
|
|
111
|
-
.send(resultString);
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
const session = existingSession;
|
|
115
|
-
existingSession = undefined;
|
|
116
|
-
await session?.instance.dispose().catch();
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
fastify.get('/profile/heap_snapshot', async (req, res) => {
|
|
120
|
-
if (existingSession) {
|
|
121
|
-
await res.status(409).send({ error: 'Profile session already in progress' });
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const filename = `heap_${Math.round(Date.now() / 1000)}.heapsnapshot`;
|
|
125
|
-
const tmpFile = path.join(os.tmpdir(), filename);
|
|
126
|
-
const fileWriteStream = fs.createWriteStream(tmpFile);
|
|
127
|
-
const heapProfiler = (0, inspector_util_1.initHeapSnapshot)(fileWriteStream);
|
|
128
|
-
existingSession = { instance: heapProfiler, response: res };
|
|
129
|
-
try {
|
|
130
|
-
// Taking a heap snapshot (with current implementation) is a one-shot process ran to get the
|
|
131
|
-
// applications current heap memory usage, rather than something done over time. So start and
|
|
132
|
-
// stop without waiting.
|
|
133
|
-
await heapProfiler.start();
|
|
134
|
-
const result = await heapProfiler.stop();
|
|
135
|
-
logger_1.logger.info(`[HeapProfiler] Completed, total snapshot byte size: ${result.totalSnapshotByteSize}`);
|
|
136
|
-
await (0, promises_1.pipeline)(fs.createReadStream(tmpFile), res.raw);
|
|
137
|
-
await res.headers({
|
|
138
|
-
'Cache-Control': 'no-store',
|
|
139
|
-
'Transfer-Encoding': 'chunked',
|
|
140
|
-
'Content-Disposition': `attachment; filename="${filename}"`,
|
|
141
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
const session = existingSession;
|
|
146
|
-
existingSession = undefined;
|
|
147
|
-
await session?.instance.dispose().catch();
|
|
148
|
-
try {
|
|
149
|
-
fileWriteStream.destroy();
|
|
150
|
-
}
|
|
151
|
-
catch (_) { }
|
|
152
|
-
try {
|
|
153
|
-
logger_1.logger.info(`[HeapProfiler] Cleaning up tmp file ${tmpFile}`);
|
|
154
|
-
fs.unlinkSync(tmpFile);
|
|
155
|
-
}
|
|
156
|
-
catch (_) { }
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
fastify.get('/profile/cancel', async (req, res) => {
|
|
160
|
-
if (!existingSession) {
|
|
161
|
-
await res.status(409).send({ error: 'No existing profile session is exists to cancel' });
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const session = existingSession;
|
|
165
|
-
await session.instance.stop().catch();
|
|
166
|
-
await session.instance.dispose().catch();
|
|
167
|
-
await session.response.status(500).send('cancelled');
|
|
168
|
-
existingSession = undefined;
|
|
169
|
-
await Promise.resolve();
|
|
170
|
-
await res.send({ ok: 'existing profile session stopped' });
|
|
171
|
-
});
|
|
172
|
-
done();
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Creates a Fastify server that controls a CPU profiler.
|
|
176
|
-
* @returns Fastify instance
|
|
177
|
-
*/
|
|
178
|
-
async function buildProfilerServer() {
|
|
179
|
-
const fastify = (0, fastify_1.default)({
|
|
180
|
-
trustProxy: true,
|
|
181
|
-
logger: logger_1.PINO_LOGGER_CONFIG,
|
|
182
|
-
}).withTypeProvider();
|
|
183
|
-
await fastify.register(CpuProfiler);
|
|
184
|
-
return fastify;
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/profiler/server.ts"],"names":[],"mappings":";;AAuMA,kDAOC;AA7MD,mCAA8B;AAE9B,yBAAyB;AACzB,6BAA6B;AAC7B,yBAAyB;AACzB,wCAAqC;AACrC,mDAAgD;AAChD,sCAAuD;AACvD,qCAAwF;AACxF,0EAA2E;AAC3E,qDAAwF;AAExF,MAAM,cAAc,GAAG,4BAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AACnD,MAAM,sBAAsB,GAAG,4BAAI,CAAC,QAAQ,CAAC,4BAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1E,MAAM,WAAW,GAA6E,CAC5F,OAAO,EACP,OAAO,EACP,IAAI,EACJ,EAAE;IACF,IAAI,eAA4F,CAAC;IAEjG,OAAO,CAAC,GAAG,CACT,cAAc,EACd;QACE,MAAM,EAAE;YACN,WAAW,EAAE,4BAAI,CAAC,MAAM,CAAC;gBACvB,QAAQ,EAAE,cAAc;gBACxB,iBAAiB,EAAE,sBAAsB;aAC1C,CAAC;SACH;KACF,EACD,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACjB,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qCAAqC,EAAE,CAAC,CAAC;YAC7E,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;QACnC,MAAM,gBAAgB,GAAG,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC;QACrD,MAAM,WAAW,GAAG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AAG,IAAA,iBAAO,EAAC;QACtB,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,2BAAkB;KAC3B,CAAC,CAAC,gBAAgB,EAAuB,CAAC;IAC3C,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SERVER_VERSION = void 0;
|
|
4
|
-
exports.getServerVersion = getServerVersion;
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const is_debugging_1 = require("../helpers/is-debugging");
|
|
7
|
-
function getServerVersion() {
|
|
8
|
-
if (process.env.NODE_ENV === 'test') {
|
|
9
|
-
return {
|
|
10
|
-
branch: 'test',
|
|
11
|
-
commit: '123456',
|
|
12
|
-
tag: 'v0.0.1',
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const [branch, commit, tag] = (0, node_fs_1.readFileSync)('.git-info', 'utf-8').split('\n');
|
|
17
|
-
return { branch, commit, tag };
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
// If .git-info file does not exist and we are debugging, return a default version
|
|
21
|
-
const fileNotExists = error.code === 'ENOENT';
|
|
22
|
-
if (fileNotExists && (0, is_debugging_1.isDebugging)()) {
|
|
23
|
-
return {
|
|
24
|
-
branch: 'debugging',
|
|
25
|
-
commit: '123456',
|
|
26
|
-
tag: 'v0.0.1',
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.SERVER_VERSION = getServerVersion();
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server-version/index.ts"],"names":[],"mappings":";;;AASA,4CAwBC;AAjCD,qCAAuC;AACvC,0DAAsD;AAQtD,SAAgB,gBAAgB;IAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QACpC,OAAO;YACL,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,IAAA,sBAAY,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,kFAAkF;QAClF,MAAM,aAAa,GAAI,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;QACzE,IAAI,aAAa,IAAI,IAAA,0BAAW,GAAE,EAAE,CAAC;YACnC,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,QAAQ;gBAChB,GAAG,EAAE,QAAQ;aACd,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAEY,QAAA,cAAc,GAAG,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type ShutdownHandler = () => void | PromiseLike<void>;
|
|
2
|
-
type ShutdownConfig = {
|
|
3
|
-
name: string;
|
|
4
|
-
handler: ShutdownHandler;
|
|
5
|
-
forceKillable: boolean;
|
|
6
|
-
forceKillHandler?: ShutdownHandler;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Start a graceful API shutdown.
|
|
10
|
-
*/
|
|
11
|
-
export declare function shutdown(): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Register shutdown handlers for different API components.
|
|
14
|
-
* @param configs - Array of shutdown configurations
|
|
15
|
-
*/
|
|
16
|
-
export declare function registerShutdownConfig(...configs: ShutdownConfig[]): void;
|
|
17
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shutdown = shutdown;
|
|
4
|
-
exports.registerShutdownConfig = registerShutdownConfig;
|
|
5
|
-
const time_1 = require("../helpers/time");
|
|
6
|
-
const logger_1 = require("../logger");
|
|
7
|
-
const SHUTDOWN_SIGNALS = ['SIGINT', 'SIGTERM'];
|
|
8
|
-
const shutdownConfigs = [];
|
|
9
|
-
let isShuttingDown = false;
|
|
10
|
-
/**
|
|
11
|
-
* Start a graceful API shutdown.
|
|
12
|
-
*/
|
|
13
|
-
async function shutdown() {
|
|
14
|
-
if (isShuttingDown) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
isShuttingDown = true;
|
|
18
|
-
const timeoutMs = parseInt(process.env['STACKS_SHUTDOWN_FORCE_KILL_TIMEOUT'] ?? '60') * 1000;
|
|
19
|
-
let errorEncountered = false;
|
|
20
|
-
for (const config of shutdownConfigs) {
|
|
21
|
-
try {
|
|
22
|
-
logger_1.logger.info(`Closing ${config.name}...`);
|
|
23
|
-
const gracefulShutdown = await (0, time_1.resolveOrTimeout)(Promise.resolve(config.handler()), timeoutMs, !config.forceKillable, () => logger_1.logger.error(`${config.name} is taking longer than expected to shutdown, possibly hanging indefinitely`));
|
|
24
|
-
if (!gracefulShutdown) {
|
|
25
|
-
if (config.forceKillable && config.forceKillHandler) {
|
|
26
|
-
await Promise.resolve(config.forceKillHandler());
|
|
27
|
-
}
|
|
28
|
-
logger_1.logger.error(`${config.name} was force killed after taking longer than ${timeoutMs}ms to shutdown`);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
logger_1.logger.info(`${config.name} closed`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
errorEncountered = true;
|
|
36
|
-
logger_1.logger.error(error, `Error running ${config.name} shutdown handler`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (errorEncountered) {
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
logger_1.logger.info('App shutdown successful.');
|
|
44
|
-
process.exit();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
let shutdownSignalsRegistered = false;
|
|
48
|
-
function registerShutdownSignals() {
|
|
49
|
-
if (shutdownSignalsRegistered) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
shutdownSignalsRegistered = true;
|
|
53
|
-
SHUTDOWN_SIGNALS.forEach(sig => {
|
|
54
|
-
process.once(sig, () => {
|
|
55
|
-
logger_1.logger.info(`Shutting down... received signal: ${sig}`);
|
|
56
|
-
void shutdown();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
process.once('unhandledRejection', error => {
|
|
60
|
-
logger_1.logger.error(error, 'unhandledRejection');
|
|
61
|
-
logger_1.logger.error('Shutting down... received unhandledRejection.');
|
|
62
|
-
void shutdown();
|
|
63
|
-
});
|
|
64
|
-
process.once('uncaughtException', error => {
|
|
65
|
-
logger_1.logger.error(error, 'uncaughtException');
|
|
66
|
-
logger_1.logger.error('Shutting down... received uncaughtException.');
|
|
67
|
-
void shutdown();
|
|
68
|
-
});
|
|
69
|
-
process.once('beforeExit', () => {
|
|
70
|
-
logger_1.logger.error('Shutting down... received beforeExit.');
|
|
71
|
-
void shutdown();
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Register shutdown handlers for different API components.
|
|
76
|
-
* @param configs - Array of shutdown configurations
|
|
77
|
-
*/
|
|
78
|
-
function registerShutdownConfig(...configs) {
|
|
79
|
-
registerShutdownSignals();
|
|
80
|
-
shutdownConfigs.push(...configs);
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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