Skip to content

Commit b6c6ba5

Browse files
committed
feat: capture a useful stack trace at the time of send call
1 parent 6628437 commit b6c6ba5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,21 @@ export class RedisClient {
219219
commands: ([string, ...RedisValue[]] | undefined)[],
220220
writer: WritableStreamDefaultWriter<Uint8Array>,
221221
) {
222+
const stack = new Error().stack;
222223
const chunks: Array<string | Uint8Array> = [];
223224
const promises = commands.map((command) => {
224225
if (!command) {
225226
return;
226227
}
227228
encodeCommand(command, chunks);
228229
return new Promise<RedisResponse>((resolve, reject) => {
229-
this.#responseQueue.push({ resolve, reject });
230+
this.#responseQueue.push({
231+
resolve,
232+
reject(error) {
233+
error.stack = stack;
234+
reject(error);
235+
},
236+
});
230237
});
231238
});
232239
for (const chunk of chunks) {

0 commit comments

Comments
 (0)