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

UI5 linter gives "Maximum call stack size exceeded" error for defineProperty call #75

Open
codeworrior opened this issue Apr 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@codeworrior
Copy link
Member

Expected Behavior

UI5 linter should process our project without running into an internal error.

Current Behavior

When executing the UI5 linter on one of our projects, we see a "Maximum call stack size exceeded" error.

Steps to Reproduce the Issue

I can't share internal URLs here. I'll provide the information via a different channel.

Context

  • UI5 linter version: 0.2.0
  • Node.js Version: 20.11.1
  • npm Version: unknown
  • OS/Platform: Linux (no further details known)
  • Browser (if relevant): n/a
  • Other information regarding your environment (optional): nothing

Log Output / Stack Trace

Run UI5 linter on project ######## in repository ######
  
  ...

  ⚠️  Process Failed With Error
  
  Error Message:
  Failed to produce report for ###################################: Maximum call stack size exceeded
  
  For details, execute the same command again with an additional '--verbose' parameter
  
      at ChildProcess.exithandler (node:child_process:422:12)
      at ChildProcess.emit (node:events:518:28)
      at maybeClose (node:internal/child_process:1105:16)
      at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
    code: 2,
    killed: false,
    signal: null,
    cmd: 'npx -c ############################/node_modules/@ui5/linter/bin/ui5lint.js --format json --details'

@codeworrior codeworrior added the bug Something isn't working label Apr 16, 2024
@RandomByte RandomByte self-assigned this Apr 17, 2024
@RandomByte
Copy link
Member

This is caused by the following kind of defineProperty call:

Object.defineProperty(globalThis, "myProp", {
	configurable: "false",
	writable: "true",
	value: window.location.search
});

If a call like this is contained in any file of the project (e.g. a test file), any other file that accesses window will run into a Maximum call stack size exceeded exception when calling the TypeScript checker#typeToString API here:

if (this.#checker.typeToString(nodeType) === "Window & typeof globalThis") {

I suspect this is a known TypeScript issue: microsoft/TypeScript#55889

Interestingly, there are multiple ways to work around it by changing the relevant code to any of the following options:

Option A

Use a variable

var locationSearch = window.location.search;
Object.defineProperty(globalThis, "myProp", {
	configurable: "false",
	writable: "true",
	value: locationSearch
});

Option B

Use window at both places

Object.defineProperty(window, "myProp", {
	configurable: "false",
	writable: "true",
	value: window.location.search
});

Option C

Use globalThis at both places

Object.defineProperty(globalThis, "myProp", {
	configurable: "false",
	writable: "true",
	value: globalThis.location.search
});

@RandomByte RandomByte changed the title UI5 linter gives "Maximum call stack size exceeded" error UI5 linter gives "Maximum call stack size exceeded" error for defineProperty call Apr 17, 2024
@flovogt
Copy link
Member

flovogt commented May 28, 2024

@RandomByte will have another look into respective findings

@RandomByte
Copy link
Member

I checked the newly reported findings and found them to have the same root cause as described in #75 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants