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

Build freezes on Creating an optimized production build ... #11716

Closed
intelcoder opened this issue Apr 7, 2020 · 7 comments · Fixed by #11733
Closed

Build freezes on Creating an optimized production build ... #11716

intelcoder opened this issue Apr 7, 2020 · 7 comments · Fixed by #11733
Labels
please add a complete reproduction The issue lacks information for further investigation

Comments

@intelcoder
Copy link

Bug report

Describe the bug

I have tried deleting .next, yarn.lock, node_modules and using latest version of nextjs.

Build freezes on Creating an optimized production build ...

while it stuck with that message. It creates .next directory.
Screen Shot 2020-04-06 at 9 18 22 PM

And routes-manifest.json
{"version":1,"pages404":true,"basePath":"","redirects":[],"rewrites":[],"headers":[],"dynamicRoutes":[]}

I am guessing build script does not feature out routes.

To Reproduce

Dev mode works fine.
I think it might happening because of my setup. I am using custom server.js due to dynamic url.

server.js

app.prepare().then(() => {
  createServer(async (req, res) => {
    // Be sure to pass `true` as the second argument to `url.parse`.
    // This tells it to parse the query portion of the URL.
    const parsedUrl = parse(req.url, true)
    const { pathname, query } = parsedUrl
    if (
      pathname === '/' ||
      pathname === '/favicon.ico' ||
      pathname.match('_next')
    ) {
      app.render(req, res, pathname, query)
    } else {
      let result
      // fetch url lookup data to know which page component should be used
      try {
        result = await instance.get('/urllookups', {
          params: {
            url: pathname.slice(1),
          },
        })
      } catch(e) {
        console.log('error', e)
      }
      res.lookups = result.data.data
      app.render(req, res, '/lookups', query)
    }
  }).listen(3000, err => {
    if (err) throw err
    console.log('> Ready on http://localhost:3000')
  })
})

.babelrc

{
  "presets": ["next/babel"],
  "plugins": [
    [
      "styled-components",
      {
        "ssr": true,
        "displayName": true,
        "preprocess": false
      }
    ]
  ]
}

Expected behavior

I expected build process works like charm.
A clear and concise description of what you expected to happen.

System information

  • OS: [macOS]
  • Browser (if applies) [chrome]
  • Version of Next.js: [tried with 9.3.4, 9.3.5-canary.4]

Additional context

Add any other context about the problem here.

@timneutkens timneutkens added the please add a complete reproduction The issue lacks information for further investigation label Apr 7, 2020
@timneutkens
Copy link
Member

timneutkens commented Apr 7, 2020

It's practically impossible to debug this without a complete reproduction. Please provide a reproduction 🙏

@intelcoder
Copy link
Author

@timneutkens Sorry about that.
I created git repo to reproduce this issue. Only different setup is probably custom server for dynamic url and config
https://github.com/intelcoder/reproduce

Let me know if you need anything

@erikdstock
Copy link
Contributor

erikdstock commented Apr 7, 2020

I believe I'm experiencing the same issue on this branch, but only if i upgrade next 9.3.0 to 9.3.4:
https://github.com/uglycaucus/uglycauc-us/tree/static-build-improvements

(Should be reproducible with a simple upgrade + yarn export)

@ijjk
Copy link
Member

ijjk commented Apr 7, 2020

Hi @intelcoder, it looks like you are placing your server.js file in your pages folder which is causing the build to stall. We are investigating how to catch this and provide a better error although only pages should be placed in your pages folder

@erikdstock
Copy link
Contributor

@Timer I was having what felt like a very similar issue and posted instructions to replicate above. Do you think this is a separate issue? Should I be opening a new one or asking for help elsewhere?

@timneutkens
Copy link
Member

Yeah you can open up a new issue.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants