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

[Bug]: Svelte HMR Breaks when using Houdini #24231

Open
rohanrajpal opened this issue Sep 19, 2023 · 6 comments
Open

[Bug]: Svelte HMR Breaks when using Houdini #24231

rohanrajpal opened this issue Sep 19, 2023 · 6 comments

Comments

@rohanrajpal
Copy link

Describe the bug

If i use https://houdinigraphql.com/, it involves setting upa houdini() plugin in the vite.config.ts, if that is enabled, HMR does not work. So currently i'm avoiding it this way

import { sveltekit } from '@sveltejs/kit/vite';
import houdini from 'houdini/vite';
import { defineConfig } from 'vite';
import { sentrySvelteKit } from '@sentry/sveltekit';

export default () => {
    return defineConfig({
        plugins: [
            ...[process.env['npm_lifecycle_event'] !== 'storybook' ? houdini() : []],
            sentrySvelteKit({
                sourceMapsUploadOptions: {
                    org: 'spur-ma',
                    project: 'spur-website',
                },
                autoUploadSourceMaps: true,
                adapter: 'vercel',
            }),
            sveltekit(),
        ],
    });
};

To Reproduce

Here is a minimum reproduction of the issue

https://github.com/rohanrajpal/houdini-storybook-hmr-bug-repro

Also conversation with the creator of houdini is going on at :
https://discord.com/channels/1024421016405016718/1152214264547905556

His initial reply

I don't think that it's linked with the schema pooling. You can check it by commenting the whatchSchema in your houdini.config.js.

That beeing said, I don't know what could be the issue ><
I'm not using storybook, so I'm not sure how to help there.

You have some graphql in your storybook?

Do you know if they transform files like Sentry, SvelteKit, Houdini?

i commented watchSchema and confirm that its not related to polling, my bad

System

Environment Info:

  System:
    OS: macOS 13.5.2
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 18.12.1 - ~/.local/share/nvm/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.2 - ~/.local/share/nvm/v18.12.1/bin/npm
  Browsers:
    Chrome: 116.0.5845.187
    Safari: 16.6
  npmPackages:
    @storybook/addon-essentials: ^7.4.2 => 7.4.2 
    @storybook/addon-interactions: ^7.4.2 => 7.4.2 
    @storybook/addon-links: ^7.4.2 => 7.4.2 
    @storybook/addon-styling: ^1.3.7 => 1.3.7 
    @storybook/blocks: ^7.4.2 => 7.4.2 
    @storybook/jest: ^0.2.2 => 0.2.2 
    @storybook/svelte: ^7.4.2 => 7.4.2 
    @storybook/sveltekit: ^7.4.2 => 7.4.2 
    @storybook/test-runner: ^0.13.0 => 0.13.0 
    @storybook/testing-library: ^0.2.1 => 0.2.1

Additional context

No response

@shilman
Copy link
Member

shilman commented Sep 20, 2023

@JReinhold any suggestions?

@JReinhold
Copy link
Contributor

I don't know why this happens. I took a look at the Houdini source code but didn't find anything meaningful.

@IanVS are we doing anything special with HMR in Vite that could get disabled by certain Vite plugins, or similar?

@rohanrajpal
Copy link
Author

@AlecAivazis @jycouet do you might have some inputs on this?

@IanVS
Copy link
Member

IanVS commented Sep 20, 2023

The only thing we do is strip hmr boundaries from stories themselves: code/builders/builder-vite/src/plugins/strip-story-hmr-boundaries.ts. With recent versions of Vite, we could remove this because the underlying bug was fixed, but in those cases there should be no hmr boundaries so the plugin just has no effect.

My only other guess is that Houdini is relying on the filesystem being structured a certain way, whereas storybook creates a virtual entrypoint file and serves that in the preview. But that's a pretty uneducated guess.

@AlecAivazis
Copy link

AlecAivazis commented Sep 23, 2023

Sorry for lagging on the response here!

There is an equivalent issue on the houdini repo that I am going to try to take on soon (HoudiniGraphql/houdini#1116 ). I'll report back here if I run into anything or need any guidance. We have to do some hacky things to bend sveltekit's router to do what we want and its possible its causing some issues. I wouldn't be offended if we just called this a houdini problem for now 😅

@rohanrajpal
Copy link
Author

Sorry for lagging on the response here!

There is an equivalent issue on the houdini repo that I am going to try to take on soon (HoudiniGraphql/houdini#1116 ). I'll report back here if I run into anything or need any guidance. We have to do some hacky things to bend sveltekit's router to do what we want and its possible its causing some issues. I wouldn't be offended if we just called this a houdini problem for now 😅

Whoops, really sorry for not searching the houdini's issue repo! I just looked up the discord channel and thought this wasnt reported, my bad.

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

5 participants