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

CLI: updating data-table causes stack-overflow #1489

Closed
niemyjski opened this issue Nov 15, 2024 · 7 comments
Closed

CLI: updating data-table causes stack-overflow #1489

niemyjski opened this issue Nov 15, 2024 · 7 comments

Comments

@niemyjski
Copy link

Describe the bug

Add any component (in my example it's data-table), then delete all the files in the folder and trigger npx shadcn-svelte@next update

Reproduction

  1. Add any component (in my example it's data-table),
  2. Delete all the files in the data-table folder
  3. Run npx shadcn-svelte@next update

Logs

RangeError: Maximum call stack size exceeded

│
└  RangeError: Maximum call stack size exceeded
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1900)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)
    at Oe (file:///C:/Users/blake/AppData/Local/npm-cache/_npx/28febf0521d8db2e/node_modules/shadcn-svelte/dist/index.js:66:1906)


### System Info

```bash
System:
    OS: Windows 11 10.0.26100
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 10.08 GB / 31.91 GB
  Binaries:
    Node: 23.2.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.3 - ~\AppData\Roaming\npm\npm.CMD
    pnpm: 9.12.3 - C:\ProgramData\chocolatey\bin\pnpm.EXE
  Browsers:
    Edge: Chromium (129.0.2792.65)
    Internet Explorer: 11.0.26100.1882

Severity

annoyance

@ieedan
Copy link
Contributor

ieedan commented Nov 15, 2024

So basically what is causing this is a circular dependency for data-table. It is trying to depend on itself and it puts it in an infinite loop:

{
	"name": "data-table",
	"type": "registry:ui",
	"dependencies": [],
	"registryDependencies": [
		"data-table"
	],
	"files": [
		{
			"path": "ui/data-table/data-table.svelte.ts",
			"type": "registry:ui"
		},
		{
			"path": "ui/data-table/flex-render.svelte",
			"type": "registry:ui"
		},
		{
			"path": "ui/data-table/index.ts",
			"type": "registry:ui"
		},
		{
			"path": "ui/data-table/render-helpers.ts",
			"type": "registry:ui"
		}
	]
},

I am gonna try and fix this right now ideally we would just not ever add self as a dependency when building the registry.

@niemyjski
Copy link
Author

niemyjski commented Nov 15, 2024

Thanks for spending time on this. We should be able to detect this by having a cached list of deps we already visited/visiting. But I agree with your statement nice find.

@ieedan
Copy link
Contributor

ieedan commented Nov 15, 2024

It may be beneficial to have it in both the CLI and when building the chunks yeah.

@ieedan
Copy link
Contributor

ieedan commented Nov 15, 2024

I want to try and fix the build but if that isn't reasonable in a short amount of time we can also just do a CLI quick fix.

@ieedan
Copy link
Contributor

ieedan commented Nov 15, 2024

Okay I got it I am gonna also add a fix to the CLI and then I'll have a PR!

ieedan added a commit to ieedan/shadcn-svelte that referenced this issue Nov 15, 2024
@ieedan
Copy link
Contributor

ieedan commented Nov 15, 2024

Also if you wouldn't mind updating the name of this issue to instead be:

updating `data-table` causes stack-overflow

It doesn't matter if the folder isn't empty or not :)

@AdrianGonz97 AdrianGonz97 changed the title cli - updating empty folder causes a stack overflow. CLI: updating data-table causes stack-overflow Nov 15, 2024
@niemyjski
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants