posthog-node 5.47.5 → 5.47.7
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/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -4
- package/dist/client.mjs +2 -5
- package/dist/entrypoints/index.node.d.ts.map +1 -1
- package/dist/entrypoints/index.node.js +1 -1
- package/dist/entrypoints/index.node.mjs +1 -1
- package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts +6 -2
- package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts.map +1 -1
- package/dist/extensions/error-tracking/modifiers/context-lines.node.js +88 -24
- package/dist/extensions/error-tracking/modifiers/context-lines.node.mjs +85 -24
- package/dist/extensions/feature-flags/feature-flags.d.ts.map +1 -1
- package/dist/extensions/feature-flags/feature-flags.js +3 -4
- package/dist/extensions/feature-flags/feature-flags.mjs +4 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/client.ts +4 -3
- package/src/entrypoints/index.node.ts +5 -1
- package/src/extensions/error-tracking/modifiers/context-lines.node.ts +131 -28
- package/src/extensions/feature-flags/feature-flags.ts +4 -7
- package/src/version.ts +1 -1
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAGhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAG/B,wBAAwB,EACxB,UAAU,EAEV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAGhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBA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,GAC7B,IAAI;IAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAeH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;YAIY,oBAAoB;IAsJlC,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/client.js
CHANGED
|
@@ -889,10 +889,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
889
889
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
890
890
|
this.errorTracking.shutdown();
|
|
891
891
|
if (this._metrics) {
|
|
892
|
-
await
|
|
893
|
-
this._metrics.flush().catch(()=>{}),
|
|
894
|
-
new Promise((resolve)=>(0, core_namespaceObject.safeSetTimeout)(resolve, Math.max(0, shutdownDeadlineMs - Date.now())))
|
|
895
|
-
]);
|
|
892
|
+
await (0, core_namespaceObject.raceWithTimeout)(this._metrics.flush().catch(()=>{}), Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
896
893
|
this._metrics.reset();
|
|
897
894
|
}
|
|
898
895
|
try {
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { version } from "./version.mjs";
|
|
2
|
-
import { PostHogCoreStateless, PostHogMetrics, PostHogPersistedProperty, isBlockedUA, isPlainObject, minimizeFlagCalledEventProperties, resolveMetricsConfig, safeSetTimeout, uuidv7 } from "@posthog/core";
|
|
2
|
+
import { PostHogCoreStateless, PostHogMetrics, PostHogPersistedProperty, isBlockedUA, isPlainObject, minimizeFlagCalledEventProperties, raceWithTimeout, resolveMetricsConfig, safeSetTimeout, uuidv7 } from "@posthog/core";
|
|
3
3
|
import { FeatureFlagError } from "./types.mjs";
|
|
4
4
|
import { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs";
|
|
5
5
|
import { FeatureFlagsPoller, InconclusiveMatchError, RequiresServerEvaluation } from "./extensions/feature-flags/feature-flags.mjs";
|
|
@@ -850,10 +850,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
850
850
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
851
851
|
this.errorTracking.shutdown();
|
|
852
852
|
if (this._metrics) {
|
|
853
|
-
await
|
|
854
|
-
this._metrics.flush().catch(()=>{}),
|
|
855
|
-
new Promise((resolve)=>safeSetTimeout(resolve, Math.max(0, shutdownDeadlineMs - Date.now())))
|
|
856
|
-
]);
|
|
853
|
+
await raceWithTimeout(this._metrics.flush().catch(()=>{}), Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
857
854
|
this._metrics.reset();
|
|
858
855
|
}
|
|
859
856
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/entrypoints/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAM1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAE9D,qBAAa,OAAQ,SAAQ,oBAAoB;IAC/C,YAAY,IAAI,MAAM;IAItB,SAAS,CAAC,iBAAiB,IAAI,cAAc;cAI1B,4BAA4B,IAAI,iBAAiB,CAAC,sBAAsB;
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/entrypoints/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAM1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAE9D,qBAAa,OAAQ,SAAQ,oBAAoB;IAC/C,YAAY,IAAI,MAAM;IAItB,SAAS,CAAC,iBAAiB,IAAI,cAAc;cAI1B,4BAA4B,IAAI,iBAAiB,CAAC,sBAAsB;CAiB5F"}
|
|
@@ -99,7 +99,7 @@ var __webpack_exports__ = {};
|
|
|
99
99
|
new _posthog_core__WEBPACK_IMPORTED_MODULE_5__.ErrorTracking.PrimitiveCoercer()
|
|
100
100
|
], _posthog_core__WEBPACK_IMPORTED_MODULE_5__.ErrorTracking.createStackParser("node:javascript", _posthog_core__WEBPACK_IMPORTED_MODULE_5__.ErrorTracking.nodeStackLineParser), [
|
|
101
101
|
(0, _extensions_error_tracking_modifiers_module_node__WEBPACK_IMPORTED_MODULE_1__.createModulerModifier)(),
|
|
102
|
-
_extensions_error_tracking_modifiers_context_lines_node__WEBPACK_IMPORTED_MODULE_2__.addSourceContext,
|
|
102
|
+
(frames)=>(0, _extensions_error_tracking_modifiers_context_lines_node__WEBPACK_IMPORTED_MODULE_2__.addSourceContext)(frames, void 0, this._logger),
|
|
103
103
|
(0, _extensions_error_tracking_modifiers_relative_path_node__WEBPACK_IMPORTED_MODULE_3__.createRelativePathModifier)()
|
|
104
104
|
]);
|
|
105
105
|
}
|
|
@@ -21,7 +21,7 @@ class PostHog extends PostHogBackendClient {
|
|
|
21
21
|
new ErrorTracking.PrimitiveCoercer()
|
|
22
22
|
], ErrorTracking.createStackParser("node:javascript", ErrorTracking.nodeStackLineParser), [
|
|
23
23
|
createModulerModifier(),
|
|
24
|
-
addSourceContext,
|
|
24
|
+
(frames)=>addSourceContext(frames, void 0, this._logger),
|
|
25
25
|
createRelativePathModifier()
|
|
26
26
|
]);
|
|
27
27
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ErrorTracking as CoreErrorTracking } from '@posthog/core';
|
|
1
|
+
import { ErrorTracking as CoreErrorTracking, type Logger } from '@posthog/core';
|
|
2
|
+
import { type FileHandle } from 'node:fs/promises';
|
|
2
3
|
export declare const MAX_CONTEXTLINES_COLNO: number;
|
|
3
4
|
export declare const MAX_CONTEXTLINES_LINENO: number;
|
|
4
|
-
export declare
|
|
5
|
+
export declare const MAX_CONTEXTLINES_FILE_SIZE: number;
|
|
6
|
+
type OpenSourceFile = (path: string, flags: number) => Promise<FileHandle>;
|
|
7
|
+
export declare function addSourceContext(frames: CoreErrorTracking.StackFrame[], openSourceFile?: OpenSourceFile, logger?: Pick<Logger, 'debug'>): Promise<CoreErrorTracking.StackFrame[]>;
|
|
8
|
+
export {};
|
|
5
9
|
//# sourceMappingURL=context-lines.node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-lines.node.d.ts","sourceRoot":"","sources":["../../../../src/extensions/error-tracking/modifiers/context-lines.node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"context-lines.node.d.ts","sourceRoot":"","sources":["../../../../src/extensions/error-tracking/modifiers/context-lines.node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAE/E,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAUxD,eAAO,MAAM,sBAAsB,EAAE,MAAa,CAAA;AAClD,eAAO,MAAM,uBAAuB,EAAE,MAAc,CAAA;AACpD,eAAO,MAAM,0BAA0B,EAAE,MAAyB,CAAA;AAGlE,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1E,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,EACtC,cAAc,GAAE,cAAqB,EACrC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAqFzC"}
|
|
@@ -24,24 +24,33 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
27
|
+
MAX_CONTEXTLINES_FILE_SIZE: ()=>MAX_CONTEXTLINES_FILE_SIZE,
|
|
28
28
|
MAX_CONTEXTLINES_COLNO: ()=>MAX_CONTEXTLINES_COLNO,
|
|
29
|
-
addSourceContext: ()=>addSourceContext
|
|
29
|
+
addSourceContext: ()=>addSourceContext,
|
|
30
|
+
MAX_CONTEXTLINES_LINENO: ()=>MAX_CONTEXTLINES_LINENO
|
|
30
31
|
});
|
|
31
32
|
const core_namespaceObject = require("@posthog/core");
|
|
32
33
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
34
|
+
const promises_namespaceObject = require("node:fs/promises");
|
|
35
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
33
36
|
const external_node_readline_namespaceObject = require("node:readline");
|
|
34
37
|
const LRU_FILE_CONTENTS_CACHE = new core_namespaceObject.ErrorTracking.ReduceableCache(25);
|
|
35
38
|
const LRU_FILE_CONTENTS_FS_READ_FAILED = new core_namespaceObject.ErrorTracking.ReduceableCache(20);
|
|
36
39
|
const DEFAULT_LINES_OF_CONTEXT = 7;
|
|
37
40
|
const MAX_CONTEXTLINES_COLNO = 1000;
|
|
38
41
|
const MAX_CONTEXTLINES_LINENO = 10000;
|
|
39
|
-
|
|
42
|
+
const MAX_CONTEXTLINES_FILE_SIZE = 10485760;
|
|
43
|
+
async function addSourceContext(frames, openSourceFile = promises_namespaceObject.open, logger) {
|
|
40
44
|
const filesToLines = {};
|
|
45
|
+
let basePath;
|
|
46
|
+
try {
|
|
47
|
+
basePath = process.cwd();
|
|
48
|
+
} catch {}
|
|
41
49
|
for(let i = frames.length - 1; i >= 0; i--){
|
|
42
50
|
const frame = frames[i];
|
|
43
51
|
const filename = frame?.filename;
|
|
44
52
|
if (!frame || 'string' != typeof filename || 'number' != typeof frame.lineno || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame)) continue;
|
|
53
|
+
if (!(0, external_node_path_namespaceObject.isAbsolute)(filename) && void 0 === basePath) continue;
|
|
45
54
|
const filesToLinesOutput = filesToLines[filename];
|
|
46
55
|
if (!filesToLinesOutput) filesToLines[filename] = [];
|
|
47
56
|
filesToLines[filename].push(frame.lineno);
|
|
@@ -50,45 +59,87 @@ async function addSourceContext(frames) {
|
|
|
50
59
|
if (0 == files.length) return frames;
|
|
51
60
|
const readlinePromises = [];
|
|
52
61
|
for (const file of files){
|
|
53
|
-
|
|
62
|
+
const cacheKey = makeSourceCacheKey(file, basePath);
|
|
63
|
+
if (void 0 === cacheKey) continue;
|
|
64
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey)) continue;
|
|
54
65
|
const filesToLineRanges = filesToLines[file];
|
|
55
66
|
if (!filesToLineRanges) continue;
|
|
56
67
|
filesToLineRanges.sort((a, b)=>a - b);
|
|
57
68
|
const ranges = makeLineReaderRanges(filesToLineRanges);
|
|
58
|
-
if (ranges.every((r)=>rangeExistsInContentCache(
|
|
59
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
60
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
|
|
69
|
+
if (ranges.every((r)=>rangeExistsInContentCache(cacheKey, r))) continue;
|
|
70
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
|
|
71
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
|
|
61
72
|
}
|
|
62
73
|
await Promise.all(readlinePromises).catch(()=>{});
|
|
63
|
-
if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
|
|
74
|
+
if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
|
|
64
75
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
65
76
|
return frames;
|
|
66
77
|
}
|
|
67
|
-
function
|
|
78
|
+
async function openRegularSourceFile(path, openSourceFile, logger) {
|
|
79
|
+
let fileHandle;
|
|
80
|
+
let isValid = false;
|
|
81
|
+
try {
|
|
82
|
+
fileHandle = await openSourceFile(path, external_node_fs_namespaceObject.constants.O_RDONLY | external_node_fs_namespaceObject.constants.O_NONBLOCK);
|
|
83
|
+
const fileStat = await fileHandle.stat();
|
|
84
|
+
if (!fileStat.isFile()) return;
|
|
85
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
86
|
+
isValid = true;
|
|
87
|
+
return fileHandle;
|
|
88
|
+
} catch {
|
|
89
|
+
return;
|
|
90
|
+
} finally{
|
|
91
|
+
if (fileHandle && !isValid) await fileHandle.close().catch(()=>{});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
|
|
95
|
+
const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
|
|
96
|
+
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
97
|
+
const openedFileHandle = fileHandle;
|
|
68
98
|
return new Promise((resolve)=>{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
99
|
+
let finished = false;
|
|
100
|
+
function destroyStreamAndResolve(stream) {
|
|
101
|
+
if (finished) return;
|
|
102
|
+
finished = true;
|
|
103
|
+
stream?.destroy();
|
|
104
|
+
openedFileHandle.close().then(resolve, resolve);
|
|
105
|
+
}
|
|
106
|
+
let stream;
|
|
107
|
+
try {
|
|
108
|
+
stream = openedFileHandle.createReadStream({
|
|
109
|
+
autoClose: false,
|
|
110
|
+
start: 0,
|
|
111
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1
|
|
112
|
+
});
|
|
113
|
+
} catch {
|
|
114
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
115
|
+
destroyStreamAndResolve();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let lineReaded;
|
|
119
|
+
try {
|
|
120
|
+
lineReaded = (0, external_node_readline_namespaceObject.createInterface)({
|
|
121
|
+
input: stream
|
|
122
|
+
});
|
|
123
|
+
} catch {
|
|
124
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
125
|
+
destroyStreamAndResolve(stream);
|
|
126
|
+
return;
|
|
76
127
|
}
|
|
77
128
|
let lineNumber = 0;
|
|
78
129
|
let currentRangeIndex = 0;
|
|
79
130
|
const range = ranges[currentRangeIndex];
|
|
80
|
-
if (void 0 === range) return void destroyStreamAndResolve();
|
|
131
|
+
if (void 0 === range) return void destroyStreamAndResolve(stream);
|
|
81
132
|
let rangeStart = range[0];
|
|
82
133
|
let rangeEnd = range[1];
|
|
83
134
|
function onStreamError() {
|
|
84
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
135
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
85
136
|
lineReaded.close();
|
|
86
137
|
lineReaded.removeAllListeners();
|
|
87
|
-
destroyStreamAndResolve();
|
|
138
|
+
destroyStreamAndResolve(stream);
|
|
88
139
|
}
|
|
89
140
|
stream.on('error', onStreamError);
|
|
90
141
|
lineReaded.on('error', onStreamError);
|
|
91
|
-
lineReaded.on('close', destroyStreamAndResolve);
|
|
142
|
+
lineReaded.on('close', ()=>destroyStreamAndResolve(stream));
|
|
92
143
|
lineReaded.on('line', (line)=>{
|
|
93
144
|
lineNumber++;
|
|
94
145
|
if (lineNumber < rangeStart) return;
|
|
@@ -112,9 +163,10 @@ function getContextLinesFromFile(path, ranges, output) {
|
|
|
112
163
|
});
|
|
113
164
|
});
|
|
114
165
|
}
|
|
115
|
-
function addSourceContextToFrames(frames, cache) {
|
|
166
|
+
function addSourceContextToFrames(frames, cache, basePath) {
|
|
116
167
|
for (const frame of frames)if (frame.filename && void 0 === frame.context_line && 'number' == typeof frame.lineno) {
|
|
117
|
-
const
|
|
168
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath);
|
|
169
|
+
const contents = void 0 === cacheKey ? void 0 : cache.get(cacheKey);
|
|
118
170
|
if (void 0 === contents) continue;
|
|
119
171
|
addContextToFrame(frame.lineno, frame, contents);
|
|
120
172
|
}
|
|
@@ -150,8 +202,18 @@ function shouldSkipContextLinesForFrame(frame) {
|
|
|
150
202
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
151
203
|
return false;
|
|
152
204
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
205
|
+
function makeSourceCacheKey(path, basePath) {
|
|
206
|
+
if ((0, external_node_path_namespaceObject.isAbsolute)(path)) return JSON.stringify([
|
|
207
|
+
null,
|
|
208
|
+
path
|
|
209
|
+
]);
|
|
210
|
+
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
211
|
+
basePath,
|
|
212
|
+
path
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
function rangeExistsInContentCache(cacheKey, range) {
|
|
216
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
|
|
155
217
|
if (void 0 === contents) return false;
|
|
156
218
|
for(let i = range[0]; i <= range[1]; i++)if (void 0 === contents[i]) return false;
|
|
157
219
|
return true;
|
|
@@ -215,10 +277,12 @@ function snipLine(line, colno) {
|
|
|
215
277
|
return newLine;
|
|
216
278
|
}
|
|
217
279
|
exports.MAX_CONTEXTLINES_COLNO = __webpack_exports__.MAX_CONTEXTLINES_COLNO;
|
|
280
|
+
exports.MAX_CONTEXTLINES_FILE_SIZE = __webpack_exports__.MAX_CONTEXTLINES_FILE_SIZE;
|
|
218
281
|
exports.MAX_CONTEXTLINES_LINENO = __webpack_exports__.MAX_CONTEXTLINES_LINENO;
|
|
219
282
|
exports.addSourceContext = __webpack_exports__.addSourceContext;
|
|
220
283
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
221
284
|
"MAX_CONTEXTLINES_COLNO",
|
|
285
|
+
"MAX_CONTEXTLINES_FILE_SIZE",
|
|
222
286
|
"MAX_CONTEXTLINES_LINENO",
|
|
223
287
|
"addSourceContext"
|
|
224
288
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ErrorTracking } from "@posthog/core";
|
|
2
|
-
import {
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { open as promises_open } from "node:fs/promises";
|
|
4
|
+
import { isAbsolute } from "node:path";
|
|
3
5
|
import { createInterface } from "node:readline";
|
|
4
6
|
const LRU_FILE_CONTENTS_CACHE = new ErrorTracking.ReduceableCache(25);
|
|
5
7
|
const LRU_FILE_CONTENTS_FS_READ_FAILED = new ErrorTracking.ReduceableCache(20);
|
|
6
8
|
const DEFAULT_LINES_OF_CONTEXT = 7;
|
|
7
9
|
const MAX_CONTEXTLINES_COLNO = 1000;
|
|
8
10
|
const MAX_CONTEXTLINES_LINENO = 10000;
|
|
9
|
-
|
|
11
|
+
const MAX_CONTEXTLINES_FILE_SIZE = 10485760;
|
|
12
|
+
async function addSourceContext(frames, openSourceFile = promises_open, logger) {
|
|
10
13
|
const filesToLines = {};
|
|
14
|
+
let basePath;
|
|
15
|
+
try {
|
|
16
|
+
basePath = process.cwd();
|
|
17
|
+
} catch {}
|
|
11
18
|
for(let i = frames.length - 1; i >= 0; i--){
|
|
12
19
|
const frame = frames[i];
|
|
13
20
|
const filename = frame?.filename;
|
|
14
21
|
if (!frame || 'string' != typeof filename || 'number' != typeof frame.lineno || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame)) continue;
|
|
22
|
+
if (!isAbsolute(filename) && void 0 === basePath) continue;
|
|
15
23
|
const filesToLinesOutput = filesToLines[filename];
|
|
16
24
|
if (!filesToLinesOutput) filesToLines[filename] = [];
|
|
17
25
|
filesToLines[filename].push(frame.lineno);
|
|
@@ -20,45 +28,87 @@ async function addSourceContext(frames) {
|
|
|
20
28
|
if (0 == files.length) return frames;
|
|
21
29
|
const readlinePromises = [];
|
|
22
30
|
for (const file of files){
|
|
23
|
-
|
|
31
|
+
const cacheKey = makeSourceCacheKey(file, basePath);
|
|
32
|
+
if (void 0 === cacheKey) continue;
|
|
33
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey)) continue;
|
|
24
34
|
const filesToLineRanges = filesToLines[file];
|
|
25
35
|
if (!filesToLineRanges) continue;
|
|
26
36
|
filesToLineRanges.sort((a, b)=>a - b);
|
|
27
37
|
const ranges = makeLineReaderRanges(filesToLineRanges);
|
|
28
|
-
if (ranges.every((r)=>rangeExistsInContentCache(
|
|
29
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
30
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
|
|
38
|
+
if (ranges.every((r)=>rangeExistsInContentCache(cacheKey, r))) continue;
|
|
39
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
|
|
40
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
|
|
31
41
|
}
|
|
32
42
|
await Promise.all(readlinePromises).catch(()=>{});
|
|
33
|
-
if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
|
|
43
|
+
if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
|
|
34
44
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
35
45
|
return frames;
|
|
36
46
|
}
|
|
37
|
-
function
|
|
47
|
+
async function openRegularSourceFile(path, openSourceFile, logger) {
|
|
48
|
+
let fileHandle;
|
|
49
|
+
let isValid = false;
|
|
50
|
+
try {
|
|
51
|
+
fileHandle = await openSourceFile(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
52
|
+
const fileStat = await fileHandle.stat();
|
|
53
|
+
if (!fileStat.isFile()) return;
|
|
54
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
55
|
+
isValid = true;
|
|
56
|
+
return fileHandle;
|
|
57
|
+
} catch {
|
|
58
|
+
return;
|
|
59
|
+
} finally{
|
|
60
|
+
if (fileHandle && !isValid) await fileHandle.close().catch(()=>{});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
|
|
64
|
+
const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
|
|
65
|
+
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
66
|
+
const openedFileHandle = fileHandle;
|
|
38
67
|
return new Promise((resolve)=>{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
let finished = false;
|
|
69
|
+
function destroyStreamAndResolve(stream) {
|
|
70
|
+
if (finished) return;
|
|
71
|
+
finished = true;
|
|
72
|
+
stream?.destroy();
|
|
73
|
+
openedFileHandle.close().then(resolve, resolve);
|
|
74
|
+
}
|
|
75
|
+
let stream;
|
|
76
|
+
try {
|
|
77
|
+
stream = openedFileHandle.createReadStream({
|
|
78
|
+
autoClose: false,
|
|
79
|
+
start: 0,
|
|
80
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1
|
|
81
|
+
});
|
|
82
|
+
} catch {
|
|
83
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
84
|
+
destroyStreamAndResolve();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let lineReaded;
|
|
88
|
+
try {
|
|
89
|
+
lineReaded = createInterface({
|
|
90
|
+
input: stream
|
|
91
|
+
});
|
|
92
|
+
} catch {
|
|
93
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
94
|
+
destroyStreamAndResolve(stream);
|
|
95
|
+
return;
|
|
46
96
|
}
|
|
47
97
|
let lineNumber = 0;
|
|
48
98
|
let currentRangeIndex = 0;
|
|
49
99
|
const range = ranges[currentRangeIndex];
|
|
50
|
-
if (void 0 === range) return void destroyStreamAndResolve();
|
|
100
|
+
if (void 0 === range) return void destroyStreamAndResolve(stream);
|
|
51
101
|
let rangeStart = range[0];
|
|
52
102
|
let rangeEnd = range[1];
|
|
53
103
|
function onStreamError() {
|
|
54
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
104
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
55
105
|
lineReaded.close();
|
|
56
106
|
lineReaded.removeAllListeners();
|
|
57
|
-
destroyStreamAndResolve();
|
|
107
|
+
destroyStreamAndResolve(stream);
|
|
58
108
|
}
|
|
59
109
|
stream.on('error', onStreamError);
|
|
60
110
|
lineReaded.on('error', onStreamError);
|
|
61
|
-
lineReaded.on('close', destroyStreamAndResolve);
|
|
111
|
+
lineReaded.on('close', ()=>destroyStreamAndResolve(stream));
|
|
62
112
|
lineReaded.on('line', (line)=>{
|
|
63
113
|
lineNumber++;
|
|
64
114
|
if (lineNumber < rangeStart) return;
|
|
@@ -82,9 +132,10 @@ function getContextLinesFromFile(path, ranges, output) {
|
|
|
82
132
|
});
|
|
83
133
|
});
|
|
84
134
|
}
|
|
85
|
-
function addSourceContextToFrames(frames, cache) {
|
|
135
|
+
function addSourceContextToFrames(frames, cache, basePath) {
|
|
86
136
|
for (const frame of frames)if (frame.filename && void 0 === frame.context_line && 'number' == typeof frame.lineno) {
|
|
87
|
-
const
|
|
137
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath);
|
|
138
|
+
const contents = void 0 === cacheKey ? void 0 : cache.get(cacheKey);
|
|
88
139
|
if (void 0 === contents) continue;
|
|
89
140
|
addContextToFrame(frame.lineno, frame, contents);
|
|
90
141
|
}
|
|
@@ -120,8 +171,18 @@ function shouldSkipContextLinesForFrame(frame) {
|
|
|
120
171
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
121
172
|
return false;
|
|
122
173
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
174
|
+
function makeSourceCacheKey(path, basePath) {
|
|
175
|
+
if (isAbsolute(path)) return JSON.stringify([
|
|
176
|
+
null,
|
|
177
|
+
path
|
|
178
|
+
]);
|
|
179
|
+
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
180
|
+
basePath,
|
|
181
|
+
path
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
function rangeExistsInContentCache(cacheKey, range) {
|
|
185
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
|
|
125
186
|
if (void 0 === contents) return false;
|
|
126
187
|
for(let i = range[0]; i <= range[1]; i++)if (void 0 === contents[i]) return false;
|
|
127
188
|
return true;
|
|
@@ -184,4 +245,4 @@ function snipLine(line, colno) {
|
|
|
184
245
|
if (end < lineLength) newLine += '...';
|
|
185
246
|
return newLine;
|
|
186
247
|
}
|
|
187
|
-
export { MAX_CONTEXTLINES_COLNO, MAX_CONTEXTLINES_LINENO, addSourceContext };
|
|
248
|
+
export { MAX_CONTEXTLINES_COLNO, MAX_CONTEXTLINES_FILE_SIZE, MAX_CONTEXTLINES_LINENO, addSourceContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flags.d.ts","sourceRoot":"","sources":["../../../src/extensions/feature-flags/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmC,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAG1G,OAAO,EAAE,2BAA2B,EAA2B,MAAM,SAAS,CAAA;AAe9E,KAAK,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,sBAAsB,CAAA;AAEzE,cAAM,WAAY,SAAQ,KAAK;gBACjB,OAAO,EAAE,MAAM;CAO5B;AAWD,cAAM,sBAAuB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,cAAM,wBAAyB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,KAAK,yBAAyB,GAAG;IAC/B,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACpF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACtD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AAW,CAwB/C;AAuGD,iBAAS,uCAAuC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAmC3E;AAED,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,uCAAuC,EACvC,WAAW,EACX,sBAAsB,EACtB,wBAAwB,EACxB,WAAW,GACZ,CAAA"}
|
|
@@ -528,10 +528,9 @@ class FeatureFlagsPoller {
|
|
|
528
528
|
clearTimeout(this.poller);
|
|
529
529
|
if (this.cacheProvider) try {
|
|
530
530
|
const shutdownResult = this.cacheProvider.shutdown();
|
|
531
|
-
if (shutdownResult instanceof Promise) await
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
]);
|
|
531
|
+
if (shutdownResult instanceof Promise) await (0, core_namespaceObject.raceWithTimeout)(shutdownResult, timeoutMs, ()=>{
|
|
532
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
|
|
533
|
+
});
|
|
535
534
|
} catch (err) {
|
|
536
535
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`));
|
|
537
536
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safeSetTimeout } from "@posthog/core";
|
|
1
|
+
import { raceWithTimeout, safeSetTimeout } from "@posthog/core";
|
|
2
2
|
import { hashSHA1 } from "./crypto.mjs";
|
|
3
3
|
const SIXTY_SECONDS = 60000;
|
|
4
4
|
const LONG_SCALE = 0xfffffffffffffff;
|
|
@@ -494,10 +494,9 @@ class FeatureFlagsPoller {
|
|
|
494
494
|
clearTimeout(this.poller);
|
|
495
495
|
if (this.cacheProvider) try {
|
|
496
496
|
const shutdownResult = this.cacheProvider.shutdown();
|
|
497
|
-
if (shutdownResult instanceof Promise) await
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
]);
|
|
497
|
+
if (shutdownResult instanceof Promise) await raceWithTimeout(shutdownResult, timeoutMs, ()=>{
|
|
498
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
|
|
499
|
+
});
|
|
501
500
|
} catch (err) {
|
|
502
501
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`));
|
|
503
502
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.47.
|
|
1
|
+
export declare const version = "5.47.7";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.47.
|
|
29
|
+
const version = '5.47.7';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.47.
|
|
1
|
+
const version = '5.47.7';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.47.
|
|
3
|
+
"version": "5.47.7",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/entrypoints/index.node.mjs",
|
|
29
29
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.46.
|
|
31
|
+
"@posthog/core": "^1.46.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edge-runtime/jest-environment": "^4.0.0",
|
package/src/client.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
Properties,
|
|
19
19
|
resolveMetricsConfig,
|
|
20
20
|
RetriableOptions,
|
|
21
|
+
raceWithTimeout,
|
|
21
22
|
safeSetTimeout,
|
|
22
23
|
uuidv7,
|
|
23
24
|
} from '@posthog/core'
|
|
@@ -2462,10 +2463,10 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2462
2463
|
// this flush runs before super._shutdown starts its own timeout, so an
|
|
2463
2464
|
// unresponsive transport must not be able to hold shutdown past the
|
|
2464
2465
|
// caller's deadline (its retry stack alone can take ~49s).
|
|
2465
|
-
await
|
|
2466
|
+
await raceWithTimeout(
|
|
2466
2467
|
this._metrics.flush().catch(() => {}),
|
|
2467
|
-
|
|
2468
|
-
|
|
2468
|
+
Math.max(0, shutdownDeadlineMs - Date.now())
|
|
2469
|
+
)
|
|
2469
2470
|
// reset() also invalidates a flush that lost the race above: when its
|
|
2470
2471
|
// send finally settles, the stale window is discarded instead of being
|
|
2471
2472
|
// merged back onto a re-armed timer after teardown.
|
|
@@ -27,7 +27,11 @@ export class PostHog extends PostHogBackendClient {
|
|
|
27
27
|
new CoreErrorTracking.PrimitiveCoercer(),
|
|
28
28
|
],
|
|
29
29
|
CoreErrorTracking.createStackParser('node:javascript', CoreErrorTracking.nodeStackLineParser),
|
|
30
|
-
[
|
|
30
|
+
[
|
|
31
|
+
createModulerModifier(),
|
|
32
|
+
(frames) => addSourceContext(frames, undefined, this._logger),
|
|
33
|
+
createRelativePathModifier(),
|
|
34
|
+
]
|
|
31
35
|
)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright (c) 2012 Functional Software, Inc. dba Sentry
|
|
3
3
|
// Licensed under the MIT License: https://github.com/getsentry/sentry-javascript/blob/develop/LICENSE
|
|
4
4
|
|
|
5
|
-
import { ErrorTracking as CoreErrorTracking } from '@posthog/core'
|
|
6
|
-
import {
|
|
5
|
+
import { ErrorTracking as CoreErrorTracking, type Logger } from '@posthog/core'
|
|
6
|
+
import { constants, type ReadStream } from 'node:fs'
|
|
7
|
+
import { open, type FileHandle } from 'node:fs/promises'
|
|
8
|
+
import { isAbsolute } from 'node:path'
|
|
7
9
|
import { createInterface } from 'node:readline'
|
|
8
10
|
|
|
9
11
|
const LRU_FILE_CONTENTS_CACHE = new CoreErrorTracking.ReduceableCache<string, Record<number, string>>(25)
|
|
@@ -14,15 +16,25 @@ const DEFAULT_LINES_OF_CONTEXT = 7
|
|
|
14
16
|
// Exported for testing purposes.
|
|
15
17
|
export const MAX_CONTEXTLINES_COLNO: number = 1000
|
|
16
18
|
export const MAX_CONTEXTLINES_LINENO: number = 10000
|
|
19
|
+
export const MAX_CONTEXTLINES_FILE_SIZE: number = 10 * 1024 * 1024
|
|
17
20
|
|
|
18
21
|
type ReadlineRange = [start: number, end: number]
|
|
22
|
+
type OpenSourceFile = (path: string, flags: number) => Promise<FileHandle>
|
|
19
23
|
|
|
20
24
|
export async function addSourceContext(
|
|
21
|
-
frames: CoreErrorTracking.StackFrame[]
|
|
25
|
+
frames: CoreErrorTracking.StackFrame[],
|
|
26
|
+
openSourceFile: OpenSourceFile = open,
|
|
27
|
+
logger?: Pick<Logger, 'debug'>
|
|
22
28
|
): Promise<CoreErrorTracking.StackFrame[]> {
|
|
23
29
|
// keep a lookup map of which files we've already enqueued to read,
|
|
24
30
|
// so we don't enqueue the same file multiple times which would cause multiple i/o reads
|
|
25
31
|
const filesToLines: Record<string, number[]> = {}
|
|
32
|
+
let basePath: string | undefined
|
|
33
|
+
try {
|
|
34
|
+
basePath = process.cwd()
|
|
35
|
+
} catch {
|
|
36
|
+
// Absolute source paths can still be processed when the working directory was removed.
|
|
37
|
+
}
|
|
26
38
|
|
|
27
39
|
// Maps preserve insertion order, so we iterate in reverse, starting at the
|
|
28
40
|
// outermost frame and closer to where the exception has occurred (poor mans priority)
|
|
@@ -40,6 +52,9 @@ export async function addSourceContext(
|
|
|
40
52
|
continue
|
|
41
53
|
}
|
|
42
54
|
|
|
55
|
+
if (!isAbsolute(filename) && basePath === undefined) {
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
43
58
|
const filesToLinesOutput = filesToLines[filename]
|
|
44
59
|
if (!filesToLinesOutput) {
|
|
45
60
|
filesToLines[filename] = []
|
|
@@ -54,8 +69,13 @@ export async function addSourceContext(
|
|
|
54
69
|
|
|
55
70
|
const readlinePromises: Promise<void>[] = []
|
|
56
71
|
for (const file of files) {
|
|
72
|
+
const cacheKey = makeSourceCacheKey(file, basePath)
|
|
73
|
+
if (cacheKey === undefined) {
|
|
74
|
+
continue
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
// If we failed to read this before, dont try reading it again.
|
|
58
|
-
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(
|
|
78
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey)) {
|
|
59
79
|
continue
|
|
60
80
|
}
|
|
61
81
|
|
|
@@ -68,12 +88,12 @@ export async function addSourceContext(
|
|
|
68
88
|
filesToLineRanges.sort((a, b) => a - b)
|
|
69
89
|
// Check if the contents are already in the cache and if we can avoid reading the file again.
|
|
70
90
|
const ranges = makeLineReaderRanges(filesToLineRanges)
|
|
71
|
-
if (ranges.every((r) => rangeExistsInContentCache(
|
|
91
|
+
if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r))) {
|
|
72
92
|
continue
|
|
73
93
|
}
|
|
74
94
|
|
|
75
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
76
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache))
|
|
95
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {})
|
|
96
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger))
|
|
77
97
|
}
|
|
78
98
|
|
|
79
99
|
// The promise rejections are caught in order to prevent them from short circuiting Promise.all
|
|
@@ -82,7 +102,7 @@ export async function addSourceContext(
|
|
|
82
102
|
// Perform the same loop as above, but this time we can assume all files are in the cache
|
|
83
103
|
// and attempt to add source context to frames.
|
|
84
104
|
if (frames && frames.length > 0) {
|
|
85
|
-
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE)
|
|
105
|
+
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath)
|
|
86
106
|
}
|
|
87
107
|
|
|
88
108
|
// Once we're finished processing an exception reduce the files held in the cache
|
|
@@ -92,25 +112,99 @@ export async function addSourceContext(
|
|
|
92
112
|
return frames
|
|
93
113
|
}
|
|
94
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Opens a bounded regular file without blocking on special files such as FIFOs.
|
|
117
|
+
* File validation and content reads use the same descriptor so path replacement cannot change what is read.
|
|
118
|
+
*/
|
|
119
|
+
async function openRegularSourceFile(
|
|
120
|
+
path: string,
|
|
121
|
+
openSourceFile: OpenSourceFile,
|
|
122
|
+
logger?: Pick<Logger, 'debug'>
|
|
123
|
+
): Promise<FileHandle | undefined> {
|
|
124
|
+
let fileHandle: FileHandle | undefined
|
|
125
|
+
let isValid = false
|
|
126
|
+
try {
|
|
127
|
+
fileHandle = await openSourceFile(path, constants.O_RDONLY | constants.O_NONBLOCK)
|
|
128
|
+
const fileStat = await fileHandle.stat()
|
|
129
|
+
if (!fileStat.isFile()) {
|
|
130
|
+
return undefined
|
|
131
|
+
}
|
|
132
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) {
|
|
133
|
+
logger?.debug(
|
|
134
|
+
`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`
|
|
135
|
+
)
|
|
136
|
+
return undefined
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
isValid = true
|
|
140
|
+
return fileHandle
|
|
141
|
+
} catch {
|
|
142
|
+
return undefined
|
|
143
|
+
} finally {
|
|
144
|
+
if (fileHandle && !isValid) {
|
|
145
|
+
await fileHandle.close().catch(() => {})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
95
150
|
/**
|
|
96
151
|
* Extracts lines from a file and stores them in a cache.
|
|
97
152
|
*/
|
|
98
|
-
function getContextLinesFromFile(
|
|
153
|
+
async function getContextLinesFromFile(
|
|
154
|
+
path: string,
|
|
155
|
+
ranges: ReadlineRange[],
|
|
156
|
+
output: Record<number, string>,
|
|
157
|
+
cacheKey: string,
|
|
158
|
+
openSourceFile: OpenSourceFile,
|
|
159
|
+
logger?: Pick<Logger, 'debug'>
|
|
160
|
+
): Promise<void> {
|
|
161
|
+
const fileHandle = await openRegularSourceFile(path, openSourceFile, logger)
|
|
162
|
+
if (fileHandle === undefined) {
|
|
163
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1)
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
const openedFileHandle = fileHandle
|
|
167
|
+
|
|
99
168
|
return new Promise((resolve) => {
|
|
169
|
+
let finished = false
|
|
170
|
+
|
|
171
|
+
// We need to explicitly destroy the stream and close its descriptor to prevent memory leaks,
|
|
172
|
+
// removing the listeners on the readline interface is not enough.
|
|
173
|
+
// Otherwise, repeated exception captures can keep opening the same files without closing them.
|
|
174
|
+
function destroyStreamAndResolve(stream?: ReadStream): void {
|
|
175
|
+
if (finished) {
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
finished = true
|
|
179
|
+
stream?.destroy()
|
|
180
|
+
void openedFileHandle.close().then(resolve, resolve)
|
|
181
|
+
}
|
|
182
|
+
|
|
100
183
|
// It is important *not* to have any async code between createInterface and the 'line' event listener
|
|
101
184
|
// as it will cause the 'line' event to
|
|
102
185
|
// be emitted before the listener is attached.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
186
|
+
let stream: ReadStream
|
|
187
|
+
try {
|
|
188
|
+
stream = openedFileHandle.createReadStream({
|
|
189
|
+
autoClose: false,
|
|
190
|
+
start: 0,
|
|
191
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1,
|
|
192
|
+
})
|
|
193
|
+
} catch {
|
|
194
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1)
|
|
195
|
+
destroyStreamAndResolve()
|
|
196
|
+
return
|
|
197
|
+
}
|
|
107
198
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
199
|
+
let lineReaded: ReturnType<typeof createInterface>
|
|
200
|
+
try {
|
|
201
|
+
lineReaded = createInterface({
|
|
202
|
+
input: stream,
|
|
203
|
+
})
|
|
204
|
+
} catch {
|
|
205
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1)
|
|
206
|
+
destroyStreamAndResolve(stream)
|
|
207
|
+
return
|
|
114
208
|
}
|
|
115
209
|
|
|
116
210
|
// Init at zero and increment at the start of the loop because lines are 1 indexed.
|
|
@@ -119,7 +213,7 @@ function getContextLinesFromFile(path: string, ranges: ReadlineRange[], output:
|
|
|
119
213
|
const range = ranges[currentRangeIndex]
|
|
120
214
|
if (range === undefined) {
|
|
121
215
|
// We should never reach this point, but if we do, we should resolve the promise to prevent it from hanging.
|
|
122
|
-
destroyStreamAndResolve()
|
|
216
|
+
destroyStreamAndResolve(stream)
|
|
123
217
|
return
|
|
124
218
|
}
|
|
125
219
|
let rangeStart = range[0]
|
|
@@ -128,18 +222,18 @@ function getContextLinesFromFile(path: string, ranges: ReadlineRange[], output:
|
|
|
128
222
|
// We use this inside Promise.all, so we need to resolve the promise even if there is an error
|
|
129
223
|
// to prevent Promise.all from short circuiting the rest.
|
|
130
224
|
function onStreamError(): void {
|
|
131
|
-
// Mark file
|
|
132
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
225
|
+
// Mark the file as failed to prevent repeated read attempts.
|
|
226
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1)
|
|
133
227
|
lineReaded.close()
|
|
134
228
|
lineReaded.removeAllListeners()
|
|
135
|
-
destroyStreamAndResolve()
|
|
229
|
+
destroyStreamAndResolve(stream)
|
|
136
230
|
}
|
|
137
231
|
|
|
138
232
|
// We need to handle the error event to prevent the process from crashing in < Node 16
|
|
139
233
|
// https://github.com/nodejs/node/pull/31603
|
|
140
234
|
stream.on('error', onStreamError)
|
|
141
235
|
lineReaded.on('error', onStreamError)
|
|
142
|
-
lineReaded.on('close', destroyStreamAndResolve)
|
|
236
|
+
lineReaded.on('close', () => destroyStreamAndResolve(stream))
|
|
143
237
|
|
|
144
238
|
lineReaded.on('line', (line) => {
|
|
145
239
|
lineNumber++
|
|
@@ -175,12 +269,14 @@ function getContextLinesFromFile(path: string, ranges: ReadlineRange[], output:
|
|
|
175
269
|
/** Adds context lines to frames */
|
|
176
270
|
function addSourceContextToFrames(
|
|
177
271
|
frames: CoreErrorTracking.StackFrame[],
|
|
178
|
-
cache: CoreErrorTracking.ReduceableCache<string, Record<number, string
|
|
272
|
+
cache: CoreErrorTracking.ReduceableCache<string, Record<number, string>>,
|
|
273
|
+
basePath: string | undefined
|
|
179
274
|
): void {
|
|
180
275
|
for (const frame of frames) {
|
|
181
276
|
// Only add context if we have a filename and it hasn't already been added
|
|
182
277
|
if (frame.filename && frame.context_line === undefined && typeof frame.lineno === 'number') {
|
|
183
|
-
const
|
|
278
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath)
|
|
279
|
+
const contents = cacheKey === undefined ? undefined : cache.get(cacheKey)
|
|
184
280
|
if (contents === undefined) {
|
|
185
281
|
continue
|
|
186
282
|
}
|
|
@@ -280,11 +376,18 @@ function shouldSkipContextLinesForFrame(frame: CoreErrorTracking.StackFrame): bo
|
|
|
280
376
|
return false
|
|
281
377
|
}
|
|
282
378
|
|
|
379
|
+
function makeSourceCacheKey(path: string, basePath: string | undefined): string | undefined {
|
|
380
|
+
if (isAbsolute(path)) {
|
|
381
|
+
return JSON.stringify([null, path])
|
|
382
|
+
}
|
|
383
|
+
return basePath === undefined ? undefined : JSON.stringify([basePath, path])
|
|
384
|
+
}
|
|
385
|
+
|
|
283
386
|
/**
|
|
284
387
|
* Checks if we have all the contents that we need in the cache.
|
|
285
388
|
*/
|
|
286
|
-
function rangeExistsInContentCache(
|
|
287
|
-
const contents = LRU_FILE_CONTENTS_CACHE.get(
|
|
389
|
+
function rangeExistsInContentCache(cacheKey: string, range: ReadlineRange): boolean {
|
|
390
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey)
|
|
288
391
|
if (contents === undefined) {
|
|
289
392
|
return false
|
|
290
393
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FeatureFlagCondition, FlagProperty, FlagPropertyValue, PostHogFeatureFlag, PropertyGroup } from '../../types'
|
|
2
2
|
import type { FeatureFlagValue, JsonType, PostHogFetchOptions, PostHogFetchResponse } from '@posthog/core'
|
|
3
|
-
import { safeSetTimeout } from '@posthog/core'
|
|
3
|
+
import { raceWithTimeout, safeSetTimeout } from '@posthog/core'
|
|
4
4
|
import { hashSHA1 } from './crypto'
|
|
5
5
|
import { FlagDefinitionCacheProvider, FlagDefinitionCacheData } from './cache'
|
|
6
6
|
|
|
@@ -1062,12 +1062,9 @@ class FeatureFlagsPoller {
|
|
|
1062
1062
|
// This follows the same timeout logic defined in _shutdown.
|
|
1063
1063
|
// We time out after some period of time to avoid hanging the entire
|
|
1064
1064
|
// shutdown process if the cache provider misbehaves.
|
|
1065
|
-
await
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
setTimeout(() => reject(new Error(`Cache shutdown timeout after ${timeoutMs}ms`)), timeoutMs)
|
|
1069
|
-
),
|
|
1070
|
-
])
|
|
1065
|
+
await raceWithTimeout(shutdownResult, timeoutMs, () => {
|
|
1066
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`)
|
|
1067
|
+
})
|
|
1071
1068
|
}
|
|
1072
1069
|
} catch (err) {
|
|
1073
1070
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`))
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.47.
|
|
1
|
+
export const version = '5.47.7'
|