Build fail but process not exit and just hanging

I have problem when my build is failing (gatsby), for example, using window or document in render without checking if it’s SSR. My build fail (which it should be) but hanging and it not exit.

account for future breakpoint definitions outside of this range.
12:56:00 AM: failed Building static HTML for pages - 2.447s
12:56:00 AM: error "window" is not available during server side rendering.
12:56:00 AM: 
12:56:00 AM:   70 |   return (
12:56:00 AM:   71 |     <div ref={cointainrRef}>
12:56:00 AM: > 72 |       {window.visualViewport.width}
12:56:00 AM:      |        ^
12:56:00 AM:   73 |       <Box id="content-issue-report">
12:56:00 AM:   74 |         <Box
12:56:00 AM:   75 |           maxWidth={310}
12:56:00 AM: 
12:56:00 AM:   WebpackError: ReferenceError: window is not defined
12:56:00 AM:   
12:56:00 AM:   - index.tsx:72 
12:56:00 AM:     src/modules/issueReportFloating/index.tsx:72:8
12:56:00 AM:   
12:56:00 AM: 
12:56:00 AM: not finished Generating image thumbnails - 240.177s
12:56:00 AM: ​
12:56:00 AM: ────────────────────────────────────────────────────────────────
12:56:00 AM:   "build.command" failed                                        
12:56:00 AM: ────────────────────────────────────────────────────────────────
12:56:00 AM: ​
12:56:00 AM:   Error message
12:56:00 AM:   Command failed with exit code 1: cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
12:56:00 AM: ​
12:56:00 AM:   Error location
12:56:00 AM:   In build.command from netlify.toml:
12:56:00 AM:   cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
12:56:00 AM: ​
12:56:00 AM:   Resolved config
12:56:00 AM:   build:
12:56:00 AM:     command: cross-env GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages
12:56:00 AM:     commandOrigin: config
12:56:00 AM:     environment:
12:56:00 AM:       - API_URL
12:56:00 AM:     functions: /opt/build/repo/netlify-function
12:56:00 AM:     publish: /opt/build/repo/public
12:56:00 AM: Caching artifacts
12:56:00 AM: Started saving node modules
12:56:01 AM: Finished saving node modules
12:56:01 AM: Started saving build plugins
12:56:01 AM: Finished saving build plugins
12:56:01 AM: Started saving yarn cache
12:56:01 AM: Finished saving yarn cache
12:56:01 AM: Started saving pip cache
12:56:01 AM: Finished saving pip cache
12:56:01 AM: Started saving emacs cask dependencies
12:56:01 AM: Finished saving emacs cask dependencies
12:56:01 AM: Started saving maven dependencies
12:56:01 AM: Finished saving maven dependencies
12:56:01 AM: Started saving boot dependencies
12:56:01 AM: Finished saving boot dependencies
12:56:01 AM: Started saving rust rustup cache
12:56:01 AM: Finished saving rust rustup cache
12:56:01 AM: Started saving go dependencies
12:56:01 AM: Finished saving go dependencies
12:58:13 AM: Canceling deploy

I know that I should check if window is undefined for SSR. The problem is when there’s error. Netlify CI show error and hanging without exit process untill it got timeout or cancel manually

hi there, did you read this already?

1 Like

Thank you. Finally after spend for 3 days. I’m able to fixes it.

For someone might face this issue. In my case, it’s because of useQuery hooks(graphql apollo) with pollInterval. I need to check if it’s SSR (by checking window is undefined) then apply poll interval time, if not, apply its value to undefined.

I also pass ssr parameter to be false for all useQuery

1 Like