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

Vite crash when switching between two significantly different branches - RangeError: Set maximum size exceeded #12062

Closed
7 tasks done
fc opened this issue Feb 15, 2023 · 29 comments
Labels
contribution welcome p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@fc
Copy link
Contributor

fc commented Feb 15, 2023

Describe the bug

In our case, by running vite in local dev and switching between our release branches with git checkout then we see the shell/vite crash and the browser die. It seems like HMR is not able to keep up with so many files changing so quickly.

Examination of the stack trace

It seems like since so many files change at the same time, it triggers this event handler many times:

watcher.on('add', (file) => {
handleFileAddUnlink(normalizePath(file), server)
})
watcher.on('unlink', (file) => {
handleFileAddUnlink(normalizePath(file), server)
})

The event handler is calling handleFileAddUnlink:

export async function handleFileAddUnlink(

Which subsequently calls updateModules:

Calls propagateUpdate at this line over-and-over again (10+ times according to stack trace):

if (propagateUpdate(importer, boundaries, subChain)) {

Then calls propagateUpdate one more time before hitting the RangeError:

const hasDeadEnd = propagateUpdate(mod, boundaries)

Finally, the exception/crash is triggered at this point:

boundaries.add({

Reproduction

not yet...

Steps to reproduce

  1. Checkout branch "A"
  2. Run yarn vite
  3. Checkout branch "B" that is significantly different than "A"
  4. Watch in the terminal and browser for the crash

System Info

Vite 4.1.1

Used Package Manager

yarn

Logs

boundaries.add({                                                                                                                                                                      
^

RangeError: Set maximum size exceeded
at Set.add (<anonymous>)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38291:20)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at updateModules (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38231:28)
at handleFileAddUnlink (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38271:9)
at FSWatcher.<anonymous> (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:61281:9)
 at FSWatcher.emit (node:events:525:35)
at FSWatcher.emitWithAll (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50325:8)
at FSWatcher._emit (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50417:8)
at FSWatcher._remove (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50680:50)
at FsEventsHandler.handleEvent (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49529:16)
at FsEventsHandler.checkExists (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49517:12)

I think the browser crash is possibly due to how HMR tries to do a full reload of the page but because the vite server crashed it shows Chrome as unavailable:
image

Possibly related stack trace that doesn't cause total crash

The stack trace below can happen but in an overlay and appears to be more recoverable.

When a lot of files change but not as many as when switching between our release branches, then it doesn't lead to a complete vite crash but it has this stack trace that displays in the vite overlay. I suspect that the stack trace below and the one above have a related cause (i.e., lots of files change):

Set maximum size exceeded
    at Set.add (<anonymous>)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38291:20)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
    at updateModules (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38231:28)
    at handleHMRUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38219:5)
    at FSWatcher.<anonymous> (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:61267:23)
    at FSWatcher.emit (node:events:525:35)
    at FSWatcher.emitWithAll (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50325:8)
    at FSWatcher._emit (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50417:8)
    at FsEventsHandler.handleEvent (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49551:14)
    at FsEventsHandler.addOrChange (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49501:8)
    at FsEventsHandler.checkExists (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js

Validations

@benatshippabo
Copy link
Contributor

So weird that we exceed 16777216 entries in the set, maybe there is a bug in invalidating set entries 🤔

@benatshippabo
Copy link
Contributor

benatshippabo commented Feb 18, 2023

actually yeah, @sapphi-red isn't this a bug?

const boundaries = new Set<{
boundary: ModuleNode
acceptedVia: ModuleNode
}>()

boundaries.add({
boundary: node,
acceptedVia: node,
})

Set are not smart enough to deduplicate objects based on their property, for this to work as intended, the entries we want deduplicated would have to reference the same variable

https://www.typescriptlang.org/play#code/JYOwLgpgTgZghgYwgAgEIHsCuIAmcoCeyA3gFDIXIBGWu+BAXMgM5hSgDmA3OZYkgAdIOAGrA4TVuxDdSAX1KkE6EK2QBbAgGUIYZAF5kICAHdkOsAB4M2PIQB8ACgCUPUposA6ODhyOylNS0dozIAOQAjGEANLwU-BBCEKLiTGEANnCZ2XBh8q7u2rrevv5xQbb0aVGxgQlJKRLhOTl5cgVKKszo6RCe6egcjh66rkA

@sapphi-red
Copy link
Member

By digging down the history, it seems this Set is intended to be used to dedupe the boundaries variable.
0974dbe#diff-54add59d921f03d4386f04ed8726faa5634abb4898f3e5a14f2c641431475781

I think it's a bug. It needs to be something like:

const boundaries = new Map<ModuleNode, Set<ModuleNode>>()
const s = boundaries.get(boundary) ?? new Set()
s.add(acceptedVia)
boundaries.set(boundary, s)

@sapphi-red sapphi-red added contribution welcome p3-minor-bug An edge case that only affects very specific usage (priority) labels Feb 18, 2023
@github-actions
Copy link

Hello @fc. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!

@fc
Copy link
Contributor Author

fc commented Feb 20, 2023

removed
(follow along with what Ben has, he's more onto the trail)..

@benatshippabo
Copy link
Contributor

@sapphi-red I am testing what you suggested below. Now when switching between branches I get the error below. SomeFile.tsx exists in the first branch but does not exist in the branch I'm switching to. I don't have a ton of time to dig into this so if someone feels inspired to take a look, feel free.

Hi @fc I made a pr #12125 that uses a hash to compare duplicated modules. Let me know if that fixes it

@fc
Copy link
Contributor Author

fc commented Feb 20, 2023

Hi @fc I made a pr #12125 that uses a hash to compare duplicated modules. Let me know if that fixes it

You the man! I'm on the road a bit and I think my local dev is messed up so will try again later today/tomorrow.

@fc
Copy link
Contributor Author

fc commented Feb 21, 2023

I made a mistake in my earlier testing so you can ignore my comment above yours.
I re-produced the original bug first to make sure I was following the right steps... then, when testing a build of your branch it now just hangs and it's been running for several minutes with no updates in the UI or output in the terminal.

Then I went through the steps again and enabled DEBUG=vite:* but it didn't output anything useful in the terminal. It says "hmr update" then just hangs/stops - maybe it's stuck in some kind of infinite or recursive loop which hints at something else going on.

Looks like I need to drop in some console.log statements to see where it is getting stuck..

Maybe this is related to the issue you reported -- #12087

@benatshippabo
Copy link
Contributor

Yeah I have this feeling it may be a cascade of errors for us too. Fixing one reveals another 🥲

@fc
Copy link
Contributor Author

fc commented Feb 22, 2023

I put in some log statements to see what files it is trying to run at. At a glance, it looks like propagateUpdate is getting called over and over again with the same/similar group of files over and over gain. A circular dependency issue?..

Using your branch, in my logs it is basically hitting this call over-and-over again:

if (propagateUpdate(importer, boundaries, subChain)) {

I re-read through the stack trace and I was actually missing in my stack trace walkthrough/explanation that it was calling that line above for 20-ish times before it did the final call to propagateUpdate and erroring out.

@benatshippabo
Copy link
Contributor

benatshippabo commented Feb 24, 2023

You may be on to something @fc there's the block of code above that is supposed to return early in the event of the circular dependency:

if (currentChain.includes(importer)) {
// circular deps is considered dead end
return true
}

But again, like for sets, this won't work if the module node is not the same reference.

Maybe it needs to be:

 if (currentChain.some((node: ModuleNode) => node.id === importer.id)) { 
   // circular deps is considered dead end 
   return true 
 } 

@fc
Copy link
Contributor Author

fc commented Feb 24, 2023

Assuming it is a bug in propagateUpdate, you should hypothetically be able trigger the infinite loop by creating a specially crafted call to propagateUpdate in a unit test.

@benatshippabo
Copy link
Contributor

Assuming it is a bug in propagateUpdate, you should hypothetically be able trigger the infinite loop by creating a specially crafted call to propagateUpdate in a unit test.

@fc okay I just pushed some updates to my branch implementing what I proposed earlier. Let's see if that helps

@fc
Copy link
Contributor Author

fc commented Feb 25, 2023

@benatshippabo I did a test but it still looks like some kind of infinite loop. I re-added my logs and it just showed that it was still calling this line a lot. I'm going to see if I can figure exactly what args/params are being initially sent to propagateUpdate as maybe it needs to be differently defined than what is in that unit test. Did your unit test go into an infinite loop or trigger the Set RangeError when you didn't have your changes added in?

Edit: Sweet, it's possible to set breakpoints in vite with NODE_OPTIONS=--inspect-brk and it's easier to inspect the full stack trace with Chrome. TBH, the actual problem isn't standing out to me yet. I want to see if I can find a way to repro with a unit test by copying the variables I can extract with the inspector.

@benatshippabo
Copy link
Contributor

@fc you are right, the test isn't comprehensive enough. Could you also share the parameters being passed to propagateUpdate, maybe the parameters in my unit test isn't covering enough

@fc
Copy link
Contributor Author

fc commented Feb 28, 2023

@benatshippabo I've been looking at this tonight. The data is just too massive and extremely nested when I look at it in the debugger. I'm not super sure how I can even copy the data out. If there are 1000s of importers and then one of those importers has 1000s of importers it will then call propagateUpdate. The hash set is 1000+. I wish I could find something more useful.
It would probably be helpful if I understood propagateUpdate better but TBH I'm pretty perplexed.

@mattrunyon
Copy link
Contributor

I will add that propagateUpdate not being properly de-duped also causes HMR performance problems. In my repo, I can change single lines that triggers 20k+ updates which is just a bunch of copies of the same 14 files actually. This only seems to happen when I use resolve.alias to include src files from other modules in my monorepo. When I don't use resolve.alias, the update array balloons to 67k. Again just the same 14 files/boundaries over and over.

mattrunyon added a commit to deephaven/web-client-ui that referenced this issue Mar 17, 2023
Fixes #727 as best we can w/o requiring major changes. HMR works best w/
functional components and that's too big of a change to switch
everything to functional components just for HMR.

Added an eslint rule which will warn about things that will almost
certainly invalidate HMR. Fixed the warnings it emitted.

Tested locally by changing some displayed text values in some panels and
seeing if the page triggered a full reload. I didn't have any specific
files/cases that triggered full reloads previously and it seems Vite 4
has made it better on its own. If we start running into cases.

Saving `GridRenderer` doesn't trigger a full page reload (didn't before
either), but massively slows the page (also had this behavior prior to
this change). The change eventually propagates and refreshes

We should keep an eye on vitejs/vite#12062
which will likely also fix the slow HMR issues on some components. There
seems to be duplication of modules in the update list and it can explode
at times (like GridRenderer triggers 14 unique modules, but 20k updates
consisting of just those 14)

BREAKING CHANGE:
Renamed `renderFileListItem` to `FileListItem`.
Renamed `RenderFileListItemProps` to `FileListItemProps`.
Removed exports for `ConsolePlugin.assertIsConsolePluginProps`,
`GridPlugin.SUPPORTED_TYPES`, `FileList.getPathFromItem`,
`FileList.DRAG_HOVER_TIMEOUT`, `FileList.getItemIcon`,
`Grid.directionForKey`, `GotoRow.isIrisGridProxyModel`, and
`Aggregations.SELECTABLE_OPTIONS`. These were all only being consumed
within their own file and are not consumed in enterprise
@ArnaudBarre
Copy link
Member

This clearly need a repro showing how to get Vite graph module getting duplicated modules (or a least showing than updates is called more times than file change events)

@mattrunyon
Copy link
Contributor

I can provide our repo with the issue if you don't mind a non-minimal repro

I placed some breakpoints in the HMR code and here's some observations

  • The node.isSelfAccepting branch is the only place boundaries are added in our case. These are duplicates of the same handful of nodes. propagateUpdate is not called from the CSS check in this branch
  • None of the other early returns are ever triggered
  • Boundaries are not added by any of the other branches
  • The continue statements in the loop over node.importers are never executed. propagateUpdate is always called at the end of that loop
  • acceptedHmrDeps is always empty. I added a size check to verify and it is always 0
  • acceptedHmrExports is always falsy

@ArnaudBarre
Copy link
Member

If you can provide a repo where git clone + (p)npm i + name of the file to edit to trigger the behaviour I can look at it.
If running the app requires external services to setup this would be complex to look at it

@mattrunyon
Copy link
Contributor

I made a branch that doesn't require any services to run. Here is the link https://github.com/mattrunyon/web-client-ui/tree/vite-hmr-demo

npm install
npm run start:app or cd packages/code-studio then npm start. The script from the root just uses lerna to execute start in packages/code-studio.

Then navigate to localhost:4000/styleguide

You can save packages/grid/src/Grid.tsx to trigger a bad state. I'm getting 5387 boundaries in the set, but only 17 unique. If you want to see something change, scroll down to the Grids section of the styleguide. Then in the render function of packages/grid/src/Grid.tsx, add style={{ border: '1px solid blue' }} to the canvas tag. For me it takes around 20-30s to reflect the change vs 1-2s if I de-dupe the boundaries set (didn't dig into why it was called so many times)

@mattrunyon
Copy link
Contributor

One other thing I noticed is it might be related to index files which re-export many modules in a monorepo. So in my repo above, Grid.tsx is re-exported by packages/grid/index.ts and then many other points import something (not necessarily the Grid component) from the grid package. Grid is not self accepting.

Other cases which I thought may trigger it would be saving something like components/src/Button.tsx. That component is re-exported by an index file which is then consumed from other packages in the monorepo. But Button.tsx is self accepting so it returns quickly

@ArnaudBarre
Copy link
Member

ArnaudBarre commented Mar 29, 2023

Oh yeah barrels exports is really bad for Vite HMR model.
I will look at it but if you want 1-2s updates for every file in your app you need to remove this and have explicit import as much as possible.
This is not always simple when import files from a shared library in a monorepo, but that's pretty cool HMR works across monorepo I think.
If the button case doesn't happen more often, it may be because you're not following fast refresh rules enough (but you should get a warning pointing to https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports in that case)

@mattrunyon
Copy link
Contributor

Noted. The barrel exports are useful for keeping our imports non-breaking since it can be consumed as import { Button } from '@deephaven/components' and if the file moves or is renamed we don't need alias files in place.

We have the eslint rule recommended by the react-swc plugin and AFAIK all of our files are valid under that rule. So usually we don't run into any invalidations.

Just another point I noticed is that class components are not self accepting but functional components are. I know functional components are better for HMR, but class components seem to work ok (even if they're just remounted and state is discarded). In our case we don't really have the resources to convert our class components to functional components and are fine with losing the state if the component is remounted.

In the propagateUpdates function, it seems there's. not anything preventing propagating from a node multiple times. Which is where the barrel files seem to suffer. Any reason to not check if a node has been propagated and stop calling the function? It looks somewhat like a DFS traversal of the graph, but right now nothing prevents a node from being traversed multiple times.

@ArnaudBarre
Copy link
Member

You could setup something to have import { Button } from '@deephaven/components/Button' but it's a lot of setup for just improving HMR. But I think inside an app the benefits of removing barrels file is worth it.

Even without the state update, the file is a boundary so that's keep HMR quick and I understand that keeping state is not worth the rewrite.

Ok this makes sense. I'm checking it now but if that's that I can fix that

@mattrunyon
Copy link
Contributor

Thanks. The propagateUpdates function is very quick on the server either way. It's the update list containing thousands of duplicates that makes the client slow. So the client plugin assumes that every item in the list needs to be updated.

But fixing propagateUpdates recrawling nodes should probably fix both the HMR issue and the issue on this ticket of overflowing the call stack with a bunch of changes. If that is indeed the case

@benatshippabo
Copy link
Contributor

would this plugin help with the barrel export issue?

@ArnaudBarre
Copy link
Member

This sounds a lot of additional tooling just to avoid writing explicit import in the first place. And most people often combine barrels export with export *
But maybe this is worth it for the UI lib in monorepos

@sapphi-red
Copy link
Member

Closing this issue as I guess it's fixed. There's two reports that confirmed #12658 fixed their issues (#12658 (comment), #12087 (comment)).

@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants