Skip to content
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

Deno.emit throws RangeError: Invalid string length with too many diagnostic messages #45

Open
helmutkian opened this issue Mar 18, 2021 · 2 comments
Labels
bug Something isn't working public API

Comments

@helmutkian
Copy link

Expected

Deno.emit should make a best effort to capture all diagnostic messages when compiling.

Actual

Large numbers of Deno.emit diagnostic messages result in a RangeError: Invalid string length due to the resulting JSON string being too large.

Steps to replicate

main.js

import * as dep from "dep";
console.log(dep);

importMap.json

{
	"imports": {
		"dep": "https://jspm.dev/npm:joi@13!cjs"
	}
}

Executing the following

Deno.emit('./main.js', {
  compilerOptions: {
    module: "commonjs",
    sourceMap: false,
    target: "es6",
    checkJs: true
  },
  importMapPath: "importMap.json"
})

yields the RangeError

thread 'main' panicked at 'Error 'RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at encodeJson (deno:core/core.js:191:20)
    at Object.jsonOpSync (deno:core/core.js:234:21)
    at exec (deno:cli/tsc/99_main_compiler.js:508:10)
    at [native_code]:1:12' contains boxed error of unknown type:
  JsError { message: "Uncaught RangeError: Invalid string length", source_line: Some("    const s = JSON.stringify(args);"), script_resource_name: Some("deno:core/core.js"), line_number: Some(191), start_column: Some(19), end_column: Some(20), frames: [], stack: Some("RangeError: Invalid string length\n    at JSON.stringify (<anonymous>)\n    at encodeJson (deno:core/core.js:191:20)\n    at Object.jsonOpSync (deno:core/core.js:234:21)\n    at exec (deno:cli/tsc/99_main_compiler.js:508:10)\n    at [native_code]:1:12") }', cli/errors.rs:35:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Changing checkJs: false results in no errors

@kitsonk kitsonk added bug Something isn't working public API labels Mar 19, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Mar 19, 2021

That is a diagnostic structure in excess of 560mb. I can't believe that would be useful. Likely the fix will be to truncate the diagnostic messages at some limit.

@helmutkian
Copy link
Author

@kitsonk Yeah, trying to actually show all those diagnostic messages is unrealistic, but the current behavior is a bit obscure with trying to comb through every import to identify the culprit. Something other than panicking would make it much easier to reason about what's going on.

@bartlomieju bartlomieju transferred this issue from denoland/deno Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working public API
Projects
None yet
Development

No branches or pull requests

2 participants