Skip to content

preact build hanging after seemingly successful build when using react-query #1554

Open
@kapnoc

Description

@kapnoc
  • Check if updating to the latest Preact version resolves the issue

Describe the bug
When using react-query's useQuery, building with prerender (default) makes preact build hang indefinitely, after a seemingly successful build (no error message, and normal looking list of created files):

 Build  [======] 95% (1.6s) emitting
                 bundle.7e56a.css ⏤  445 B
              bundle.*****.esm.js ⏤  20.8 kB
           polyfills.*****.esm.js ⏤  2.18 kB
       route-home.chunk.e6c71.css ⏤  74 B
    route-home.chunk.*****.esm.js ⏤  288 B
    route-profile.chunk.62c75.css ⏤  77 B
 route-profile.chunk.*****.esm.js ⏤  469 B
        route-home.chunk.723ad.js ⏤  291 B
                       index.html ⏤  1.24 kB
                         200.html ⏤  829 B
               polyfills.3cf93.js ⏤  2.17 kB
     route-profile.chunk.8b71c.js ⏤  486 B
                  bundle.73fb3.js ⏤  20.8 kB

This doesn't hang, and does exit normally when using preact build --no-prerender
There is also no problems running this with preact watch

To Reproduce

Steps to reproduce the behavior:

  1. Create default app with preact create
  2. Add react-query dep, in my case: "react-query": "^3.15.2"
  3. Change src/components/app.js to :
import { h } from 'preact';
import { Router } from 'preact-router';
import { QueryClient, QueryClientProvider, useQuery } from 'react-query'

import Header from './header';

// Code-splitting is automated for `routes` directory
import Home from '../routes/home';
import Profile from '../routes/profile';

export const queryClient = new QueryClient()

const TestElement = () => {
	const { data, isLoading } = useQuery('test', () => 'test1')
	if (isLoading) {
		return (<span>Loading...</span>)
	}

	return (<span>{data}</span>)
}

const App = () => (
	<div id="app">
		<QueryClientProvider client={queryClient}>
			<Header />
			<TestElement />
			<Router>
				<Home path="/" />
				<Profile path="/profile/" user="me" />
				<Profile path="/profile/:user" />
			</Router>
		</QueryClientProvider>
	</div>
)

export default App;
  1. Run preact build

Expected behavior
I would expect the build to exit after the files are built. In that test case, useQuery should receive instantly resolving test data, so I don't see the hang coming from "trying to get data to render".

This could of course be expected behaviour that I am not aware of, which I guess could be documented somewhere.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions