-
-
Notifications
You must be signed in to change notification settings - Fork 906
fix(oxfmt): avoid embedded TSFN crash by returning errors as data #19742
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -36,7 +36,9 @@ pub async fn run_cli( | |||||
| args: Vec<String>, | ||||||
| #[napi(ts_arg_type = "(numThreads: number) => Promise<string[]>")] | ||||||
| init_external_formatter_cb: JsInitExternalFormatterCb, | ||||||
| #[napi(ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string>")] | ||||||
| #[napi( | ||||||
| ts_arg_type = "(options: Record<string, any>, code: string) => Promise<{ ok: boolean; code?: string; error?: string }>" | ||||||
| )] | ||||||
| format_embedded_cb: JsFormatEmbeddedCb, | ||||||
| #[napi(ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string>")] | ||||||
| format_file_cb: JsFormatFileCb, | ||||||
|
|
@@ -140,7 +142,9 @@ pub async fn format( | |||||
| options: Option<Value>, | ||||||
| #[napi(ts_arg_type = "(numThreads: number) => Promise<string[]>")] | ||||||
| init_external_formatter_cb: JsInitExternalFormatterCb, | ||||||
| #[napi(ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string>")] | ||||||
| #[napi( | ||||||
| ts_arg_type = "(options: Record<string, any>, code: string) => Promise<{ ok: boolean; code?: string; error?: string }>" | ||||||
| )] | ||||||
|
Comment on lines
+145
to
+147
|
||||||
| format_embedded_cb: JsFormatEmbeddedCb, | ||||||
| #[napi(ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string>")] | ||||||
| format_file_cb: JsFormatFileCb, | ||||||
|
|
@@ -176,7 +180,9 @@ pub async fn js_text_to_doc( | |||||
| parent_context: String, | ||||||
| #[napi(ts_arg_type = "(numThreads: number) => Promise<string[]>")] | ||||||
| init_external_formatter_cb: JsInitExternalFormatterCb, | ||||||
| #[napi(ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string>")] | ||||||
| #[napi( | ||||||
| ts_arg_type = "(options: Record<string, any>, code: string) => Promise<{ ok: boolean; code?: string; error?: string }>" | ||||||
|
||||||
| ts_arg_type = "(options: Record<string, any>, code: string) => Promise<{ ok: boolean; code?: string; error?: string }>" | |
| ts_arg_type = "(options: Record<string, any>, code: string) => Promise<string | { ok: boolean; code?: string; error?: string }>" |
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.
The Rust side now accepts a legacy plain
stringresult for backward compatibility (parse_embedded_callback_result), but thists_arg_typeonly allows the wrapped{ ok, code?, error? }object. If backward compatibility is intended, update the TypeScript callback type to includePromise<string | { ok: boolean; code?: string; error?: string }>; otherwise consider removing the legacy parsing path to keep runtime and types aligned.