fix: Improve post-dataloader stack traces.#1384
Merged
Merged
Conversation
Any time a batched operation fails, it will fail in "the other context",
where the error.stack doesn't know about the caller-who-is-blocking's
context/stack.
And so it's error.stack will not include the caller's own stack:
```
error: SELECT a.* FROM authors AS a WHERE a.id = $1 ORDER BY a.id ASC LIMIT $2 - invalid input syntax for type integer: "0.6931471805599453"
at Object.raw (/home/stephen/other/joist-orm/node_modules/knex/lib/knex-builder/make-knex.js:116:30)
at Function.value (/home/stephen/other/joist-orm/node_modules/knex/lib/knex-builder/make-knex.js:92:29)
at PostgresDriver.executeQuery (/home/stephen/other/joist-orm/packages/orm/src/drivers/PostgresDriver.ts:69:8)
at PostgresDriver.executeFind (/home/stephen/other/joist-orm/packages/orm/src/drivers/PostgresDriver.ts:63:17)
at DataLoader.em.getLoader.cacheKeyFn [as _batchLoadFn] (/home/stephen/other/joist-orm/packages/orm/src/dataloaders/findDataLoader.ts:61:38)
at dispatchBatch (/home/stephen/other/joist-orm/node_modules/dataloader/index.js:288:27)
at /home/stephen/other/joist-orm/node_modules/dataloader/index.js:268:5
at processTicksAndRejections (node:internal/process/task_queues:85:11)
```
We can only tell "someone asked the dataloader to batch this".
With the appendStack, we see who the caller was:
```
error: SELECT a.* FROM authors AS a WHERE a.id = $1 ORDER BY a.id ASC LIMIT $2 - invalid input syntax for type integer: "0.6931471805599453"
at Object.raw (/home/stephen/other/joist-orm/node_modules/knex/lib/knex-builder/make-knex.js:116:30)
at Function.value (/home/stephen/other/joist-orm/node_modules/knex/lib/knex-builder/make-knex.js:92:29)
at PostgresDriver.executeQuery (/home/stephen/other/joist-orm/packages/orm/src/drivers/PostgresDriver.ts:69:8)
at PostgresDriver.executeFind (/home/stephen/other/joist-orm/packages/orm/src/drivers/PostgresDriver.ts:63:17)
at DataLoader.em.getLoader.cacheKeyFn [as _batchLoadFn] (/home/stephen/other/joist-orm/packages/orm/src/dataloaders/findDataLoader.ts:61:38)
at dispatchBatch (/home/stephen/other/joist-orm/node_modules/dataloader/index.js:288:27)
at /home/stephen/other/joist-orm/node_modules/dataloader/index.js:268:5
at processTicksAndRejections (node:internal/process/task_queues:85:11)
at find (/home/stephen/other/joist-orm/packages/orm/src/EntityManager.ts:331:32) <== new lines
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at EntityManager.find (/home/stephen/other/joist-orm/packages/orm/src/EntityManager.ts:328:20)
at Object.<anonymous> (/home/stephen/other/joist-orm/packages/tests/integration/src/EntityManager.queries.test.ts:76:21)
```
stephenh
pushed a commit
that referenced
this pull request
Mar 1, 2025
## [1.228.9](v1.228.8...v1.228.9) (2025-03-01) ### Bug Fixes * Improve post-dataloader stack traces. ([#1384](#1384)) ([62740e4](62740e4))
Collaborator
Author
|
🎉 This PR is included in version 1.228.9 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any time a batched operation fails, it will fail in "the other context" / the dataloader's setTimeout-d callback, where the error.stack doesn't know about the caller-who-is-blocking's context/stack.
And so it's error.stack will not include the caller's own stack:
We can only tell "someone asked the dataloader to batch this".
With the appendStack, we see who the caller was:
Fixes #1383