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

Blitz deploy fails on Render.com #785

Closed
SigurdMW opened this issue Aug 25, 2020 · 14 comments · Fixed by blitz-js/blitz#1045
Closed

Blitz deploy fails on Render.com #785

SigurdMW opened this issue Aug 25, 2020 · 14 comments · Fixed by blitz-js/blitz#1045

Comments

@SigurdMW
Copy link
Contributor

SigurdMW commented Aug 25, 2020

What is the problem?

Blitz fails when deploying to Render.com with the following render.yaml file:

services:
  - type: web
    name: someweb
    env: node
    plan: starter
    buildCommand: yarn; blitz db migrate; blitz build
    startCommand: blitz start --production -H 0.0.0.0
    envVars:
      - key: NODE_ENV
        value: production
      - key: DATABASE_URL
        fromDatabase:
          name: somedb
          property: connectionString
databases:
  - name: somedb
    plan: starter

Steps to Reproduce

  1. Install a brand new Blitz app
  2. Add render.yaml file as above
  3. See it fail :/

Versions

happens both on version 0.18.0 and 0.17.1-canary.7

Other

==> Starting service with 'blitz start --production -H 0.0.0.0'
Aug 25 08:08:24 PM You are using alpha software - if you have any problems, please open an issue here:
Aug 25 08:08:24 PM https://github.com/blitz-js/blitz/issues/new/choose
Aug 25 08:08:24 PM
Aug 25 08:08:30 PM - Preparing for launch
Aug 25 08:08:42 PM ✔ Prepped for launch
Aug 25 08:08:45 PM warn - You have enabled experimental feature(s).
Aug 25 08:08:45 PM warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
Aug 25 08:08:45 PM
Aug 25 08:08:45 PM warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
Aug 25 08:08:45 PM info - Creating an optimized production build...
Aug 25 08:08:45 PM Attention: Next.js now collects completely anonymous telemetry regarding usage.
Aug 25 08:08:45 PM This information is used to shape Next.js' roadmap and prioritize features.
Aug 25 08:08:45 PM You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
Aug 25 08:08:45 PM https://nextjs.org/telemetry
Aug 25 08:08:45 PM
Aug 25 08:09:02 PM Failed to compile.
Aug 25 08:09:02 PM
Aug 25 08:09:02 PM ./test/utils.tsx:3:41
Aug 25 08:09:02 PM Type error: Cannot find module '@testing-library/react' or its corresponding type declarations.
Aug 25 08:09:02 PM
Aug 25 08:09:02 PM 1 | import React from "react"
Aug 25 08:09:02 PM 2 | import { RouterContext, BlitzRouter } from "blitz"
Aug 25 08:09:02 PM > 3 | import { render as defaultRender } from "@testing-library/react"
Aug 25 08:09:02 PM | ^
Aug 25 08:09:02 PM 4 | import { renderHook as defaultRenderHook } from "@testing-library/react-hooks"
Aug 25 08:09:02 PM 5 |
Aug 25 08:09:02 PM 6 | export * from "@testing-library/react"
Aug 25 08:09:02 PM 'next build' failed with status code: 1

@merelinguist
Copy link
Contributor

Thanks for the report! I assume you do have react testing library installed?

@SigurdMW
Copy link
Contributor Author

@merelinguist I haven't done anything after running blitz new when it comes to test. Do I have to install something myself when it ships with these tests as default?

@SigurdMW
Copy link
Contributor Author

If you need more info, here is the complete code: https://github.com/SigurdMW/din-advent
I would like to help fix this and update the documentation if needed.

@merelinguist
Copy link
Contributor

Hmm you shouldn’t have to install anything then. This is a long shot, but can you try replacing moduleDirectories: ["node_modules", "."], with moduleDirectories: ["node_modules", "<rootDir>/node_modules", "."], in your jest.config.js? Otherwise, I’m sure someone else will have some more ideas.

@flybayer
Copy link
Member

Yeah @merelinguist suggestion should fix it. We are adding that to new apps by default in blitz-js/blitz#924

@SigurdMW
Copy link
Contributor Author

Unfortunately, it does not fix this. Still same error after doing you suggested changes in commit:
https://github.com/SigurdMW/din-advent/commit/4e85f99dfc36864e65e7d6238c914cf7f731e50b

Aug 25 08:59:33 PM warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
Aug 25 08:59:33 PM
Aug 25 08:59:33 PM warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
Aug 25 08:59:33 PM info - Creating an optimized production build...
Aug 25 08:59:33 PM Attention: Next.js now collects completely anonymous telemetry regarding usage.
Aug 25 08:59:33 PM This information is used to shape Next.js' roadmap and prioritize features.
Aug 25 08:59:33 PM You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
Aug 25 08:59:33 PM https://nextjs.org/telemetry
Aug 25 08:59:33 PM
Aug 25 08:59:50 PM Failed to compile.
Aug 25 08:59:50 PM
Aug 25 08:59:50 PM ./test/utils.tsx:3:41
Aug 25 08:59:50 PM Type error: Cannot find module '@testing-library/react' or its corresponding type declarations.
Aug 25 08:59:50 PM
Aug 25 08:59:50 PM 1 | import React from "react"
Aug 25 08:59:50 PM 2 | import { RouterContext, BlitzRouter } from "blitz"
Aug 25 08:59:50 PM > 3 | import { render as defaultRender } from "@testing-library/react"
Aug 25 08:59:50 PM | ^
Aug 25 08:59:50 PM 4 | import { renderHook as defaultRenderHook } from "@testing-library/react-hooks"
Aug 25 08:59:50 PM 5 |
Aug 25 08:59:50 PM 6 | export * from "@testing-library/react"
Aug 25 08:59:50 PM 'next build' failed with status code: 1

@SigurdMW
Copy link
Contributor Author

SigurdMW commented Aug 25, 2020

Oh, they had an option to clear build cache and try again. Trying that now. EDIT: same error after clear build cache

@flybayer
Copy link
Member

@SigurdMW hmm, can you try moving all your devDependencies to dependencies?

@SigurdMW
Copy link
Contributor Author

Ok nice, that did seem to work @flybayer. The site seems to be running fine now.
Do you have an idea about why and how to fix this for future cases?

@flybayer
Copy link
Member

Ok cool. If you have time, could you isolate which devDependency(s) need to be in the production deps? Probably it's just the testing-library dependency.

I see options:

  1. Move testing library to regular deps by default
  2. Try to figure out why Next.js is processing the test utils file and prevent that

@SigurdMW
Copy link
Contributor Author

SigurdMW commented Sep 2, 2020

I think the 2nd option is the best, but I have not been able to figure it out. Should I create a PR for option blitz-js/blitz#1 or let someone else tackle it?

@flybayer
Copy link
Member

flybayer commented Sep 2, 2020

Looks like this is a longstanding issue with Next.

I think we should fix this at our compilation step so that no test files get copied to the actual Next.js build. Basically we add the following to this ignore list.

    "test/**/*",
    "tests/**/*",
    "spec/**/*",
    "specs/**/*",
    "**/*.test.*",
    "**/*.spec.*",

@ryardley what do you think about this?

@ryardley
Copy link
Contributor

ryardley commented Sep 3, 2020

I agree let’s allow these to be ignored but I think it should not be ignored by default and be added to the docs as being configurable from blitz.config. What if you had a /pages/test/manage.tsx route? Also some folks like using other folder names. We can make the new generator create our default list.

@flybayer
Copy link
Member

flybayer commented Sep 3, 2020

@ryardley ok cool. Having a way to add files to the ignore list would be good. I also think we should have the most common ignored by default.

Unless I'm missing something, my suggestion would not affect pages/test/stuff.tsx. Here's what I think it would ignore:

  • <project-root>/test
  • <project-root>/tests
  • <project-root>/spec
  • <project-root>/specs
  • *.test.* anywhere in the project
  • *.spec.* anywhere in the project

SigurdMW referenced this issue in SigurdMW/blitz Sep 11, 2020
Update the default ignore path ref #942
@dillondotzip dillondotzip transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants