chia-agent 14.3.4 → 14.3.5
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/CHANGELOG.md +4 -0
- package/logger.js +32 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [14.3.5]
|
|
4
|
+
### Fixed
|
|
5
|
+
- Fixed an issue where it exhausts heap when logging an object with circular references
|
|
6
|
+
|
|
3
7
|
## [14.3.4]
|
|
4
8
|
### Breaking change
|
|
5
9
|
- Changed `daemon.connect()` API signature from `connect(url?, timeoutMs?)` to `connect(url?, options?)`
|
package/logger.js
CHANGED
|
@@ -174,19 +174,38 @@ function stringify(obj, indent) {
|
|
|
174
174
|
else if (typeof obj === "function") {
|
|
175
175
|
return "[Function]";
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
seen
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
177
|
+
else if (obj === null) {
|
|
178
|
+
return "null";
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
// Custom replacer for circular references
|
|
182
|
+
const getCircularReplacer = () => {
|
|
183
|
+
const seen = new WeakSet();
|
|
184
|
+
return (_key, value) => {
|
|
185
|
+
if (typeof value === "object" && value !== null) {
|
|
186
|
+
if (seen.has(value)) {
|
|
187
|
+
return "[Circular]";
|
|
188
|
+
}
|
|
189
|
+
seen.add(value);
|
|
190
|
+
}
|
|
191
|
+
else if (typeof value === "bigint") {
|
|
192
|
+
return `${value}n`;
|
|
193
|
+
}
|
|
194
|
+
else if (typeof value === "function") {
|
|
195
|
+
return "[Function]";
|
|
196
|
+
}
|
|
197
|
+
else if (typeof value === "symbol") {
|
|
198
|
+
return value.toString();
|
|
199
|
+
}
|
|
200
|
+
return value;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
return JSON.stringify(obj, getCircularReplacer(), indent);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const msg = error && typeof error === "object" && "message" in error ? error.message : "Unknown error";
|
|
207
|
+
return `[Error stringifying object: ${msg}]`;
|
|
208
|
+
}
|
|
190
209
|
}
|
|
191
210
|
class Logger {
|
|
192
211
|
constructor(name, logLevel, writer, formatter) {
|