-
Notifications
You must be signed in to change notification settings - Fork 2
fix: error stack traces in transpiled TypeScript #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fe71fc0
fix: error stack traces in transpiled TypeScript
bajtos 24155c1
Merge branch 'main' into test-typescript-modules
bajtos eb991a2
fixup! normalize line endings
bajtos ff644be
fixup! clarify comment
bajtos 822d7b7
fixup! syntax
bajtos f19cff8
Merge branch 'main' into test-typescript-modules
bajtos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/runtime/vendored | ||
/runtime/js/vendored | ||
target | ||
/runtime/tests/js/typescript_fixtures/typescript_stack_trace.ts | ||
|
||
# Let's keep LICENSE.md in the same formatting as we use in other PL repositories | ||
LICENSE.md |
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
14 changes: 14 additions & 0 deletions
14
runtime/tests/js/typescript_fixtures/typescript_stack_trace.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// This TypeScript-only block of code is removed during transpilation. A naive solution that removes | ||
// the TypeScript code instead of replacing it with whitespace and does not apply source maps to error | ||
// stack traces will lead to incorrect line numbers in error stack traces. | ||
interface User { | ||
name: string; | ||
email: string; | ||
} | ||
|
||
// The part `: Error` changes the source column number | ||
// between the TypeScript original and the transpiled code. | ||
// | ||
// Throw the error so that the test can verify source code line & column numbers | ||
// in the stack trace frames but also the source code of the line throwing the exception. | ||
const error: Error = new Error(); throw error; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the module loader exclusively single threaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! I am not sure, TBH.
We are running the Deno runtime on the current thread, see here:
zinnia/daemon/main.rs
Line 21 in 2d40376
zinnia/cli/main.rs
Line 17 in 2d40376
I think that means all async tasks will be executed on the current thread too, including the asynchronous work of the module loader.
Deno uses
Rc<RefCell<...>>
in their example:https://github.com/denoland/deno_core/blob/0.343.0/core/examples/ts_module_loader.rs
My knowledge of async Rust is very limited, I don't understand this deeply enough. What would you suggest to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, well
Rc<RefCell<...>>
is used in a single-threaded environment, since Deno is using that as an example, I would assume it is single threaded. If we were to use multithreaded environments, I'd rather go for aArc<Mutex<...>>
type.