Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Help: Zeit Now V2 Deployment #130

Open
williamluke4 opened this issue Apr 11, 2019 · 27 comments
Open

Help: Zeit Now V2 Deployment #130

williamluke4 opened this issue Apr 11, 2019 · 27 comments

Comments

@williamluke4
Copy link

Does anyone have experence deploying Yoga 2 to Now V2. I have been trying on and off for a week now with no avail. Below is my now.json

{
  "name": "api.domain.com",
  "alias": ["api.domain.com"],
  "version": 2,
  "builds": [{ "src": "dist/src/index.js", "use": "@now/node-server" }],
  "routes": [
    { "src": "/.*", "dest": "dist/src/index.js"}
  ]
}

@DevanB
Copy link
Contributor

DevanB commented Apr 11, 2019

I've been working for about two weeks on deploying to Now v2 also.

I've now gotten a Now customer service employee helping me figure out why the deployment isn't working correctly.

So far, the issues seems to be with NCC and on Now's side. However, they are looking at one more deployment of a yoga2 server that did work.

I might know more today; I'll keep this comment updated as I learn more.

@williamluke4
Copy link
Author

Ok awesome, this has been driving me nuts!!

I am looking in to implementing apollo-server-lambda in to yoga2, do you think that this would be worth while?

@Weakky
Copy link
Contributor

Weakky commented Apr 11, 2019

Hey 👋,

Could you please provide a bit more context? We have deployed a yoga2 server recently using the very same now.json file as you do and had no issue doing so

@DevanB
Copy link
Contributor

DevanB commented Apr 11, 2019

I've been trying to deploy this project. However, an employee at Zeit tells me it keeps erring out due to NCC not working correctly.

@williamluke4
Copy link
Author

Hey @DevanB, Have you heard back from Zeit?

@DevanB
Copy link
Contributor

DevanB commented Apr 13, 2019

Nope no response. I know another developer I was talking to deployed a yoga2 server with no luck also.

@Weakky - I deployed your Prisma e-commerce branch and it deployed, but doesn’t work correctly. For instance, you can’t hit the playground and seems you can’t make any requests into it.

@williamluke4
Copy link
Author

Hey @DevanB, what output do you get when running now dev bear in mind that this only work on mac and linux atm. If you are on windows you can use wsl

@DevanB
Copy link
Contributor

DevanB commented Apr 15, 2019

@williamluke4 I actually got it working with node dev last night. But still no luck deploying

@williamluke4
Copy link
Author

Running now dev should give you a better idea of why it is not working when deployed. Just want to check to see if it is the same error that I am receiving

@DevanB
Copy link
Contributor

DevanB commented Apr 15, 2019 via email

@williamluke4
Copy link
Author

Have you tried accessing the playground after running it

@williamluke4
Copy link
Author

That is very weird as now dev uses ncc

@Weakky
Copy link
Contributor

Weakky commented Apr 15, 2019

There are two things to take into consideration here:

  • The playground is disabled by default by apollo-server when NODE_ENV=production
  • Introspection queries are also disabled when NODE_ENV=production

One workaround for now is to eject and set playground: true in the apollo-server instantiation.

Regarding the ncc error, there's nothing I can do without any logging. Someone recently reached to me to deploy yoga to now2 and succeeded without issue (once he knew he had to manually force playground: true)

@williamluke4
Copy link
Author

@Weakky, Correct... I have tried with both introspection enabled and disabled; The same for the playground

@williamluke4
Copy link
Author

Here are the logs

will@DESKTOP-4LJJ71K:/mnt/c/Users/willi/Documents/Atto-Byte/Development/api-server$ now dev
 > No existing credentials found. Please log in:
We sent an email to [email protected]. Please follow the steps provided
inside it and make sure the security code matches Famous Dragon.
✔ Email confirmed
Ready! Authentication token and personal details saved in "~/.now"
will@DESKTOP-4LJJ71K:/mnt/c/Users/willi/Documents/Atto-Byte/Development/api-server$ now dev
Running initial builds
downloading user files...
installing dependencies for user's code...
installing to /tmp/co.zeit.now/dev/workPaths/rrlku858/user/dist/src
 > [email protected] postinstall /tmp/co.zeit.now/dev/workPaths/rrlku858/user/node\_modules/protobufjs
node scripts/postinstall
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node\_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 1029 packages from 704 contributors in 134.974s
writing ncc package.json...
installing dependencies for ncc...
installing to /tmp/co.zeit.now/dev/workPaths/rrlku858/ncc
yarn install v1.10.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.15.2", while you're on "1.10.1".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
Done in 11.51s.
running user script...
preparing lambda files...
compiling entrypoint with ncc...
ncc: Version 0.17.3
ncc: Compiling file index.js
ncc: Module directory "/tmp/co.zeit.now/dev/workPaths/rrlku858/user/node\_modules/ws/lib" attempted to require "bufferutil" but could not be resolved, assuming external.
ncc: Module directory "/tmp/co.zeit.now/dev/workPaths/rrlku858/user/node\_modules/ws/lib" attempted to require "utf-8-validate" but could not be resolved, assuming external.
ncc: Module directory "/tmp/co.zeit.now/dev/workPaths/rrlku858/user/node\_modules/subscriptions-transport-ws/node\_modules/ws/lib" attempted to require "utf-8-validate" but could not be resolved, assuming external.
ncc: Module directory "/tmp/co.zeit.now/dev/workPaths/rrlku858/user/node\_modules/subscriptions-transport-ws/node\_modules/ws/lib" attempted to require "bufferutil" but could not be resolved, assuming external.
downloading user files...
installing dependencies for user's code...
installing to /tmp/co.zeit.now/dev/workPaths/pemcn11o/user/dist/src
 > Success! Initial builds completey-parser: sill tarball trying [email protected] by hash: sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==
Ready! Development server running at http://localhost:3000
 > [email protected] postinstall /tmp/co.zeit.now/dev/workPaths/pemcn11o/user/node\_modules/protobufjs
node scripts/postinstall
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node\_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 1029 packages from 704 contributors in 146.816s
writing ncc package.json...
installing dependencies for ncc...
installing to /tmp/co.zeit.now/dev/workPaths/pemcn11o/ncc
yarn install v1.10.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 1.21s.
 > GET /
GraphQL Nexus: Unable to find file or module /tmp/zeit-fun-50baea9e77c81/user/dist/src/context.ts, skipping
GraphQL Nexus: Unable to find file or module /tmp/zeit-fun-50baea9e77c81/user/dist/.yoga/prisma-client/index.ts, skipping
Missing required typegen import: ctx
POST /
Error: Body exceeded 1mb limit
at f (/snapshot/repo/dist/index.js:1:2075329)
at module.exports.7487.t.buffer.Promise.resolve.then.a.then.catch.e (/snapshot/repo/dist/index.js:1:2076888)
at process.\_tickCallback (internal/process/next\_tick.js:68:7)
Error: Unexpected /invocation/response response: {"statusCode":413,"headers":{"content-length":"23","date":"Mon, 15 Apr 2019 12:53:35 GMT","connection":"close"},"body":"Body exceeded 1mb limit"}
at /home/will/src/runtimes/nodejs/bootstrap.ts:155:9
at Generator.next (<anonymous>)
at fulfilled (/home/will/.cache/co.zeit.fun/runtimes/nodejs/bootstrap.js:4:58)
at <anonymous>
at process.\_tickCallback (internal/process/next\_tick.js:188:7)
LambdaError: RequestId: 3f2afa08-8744-44d8-9b13-7e15a576dcee Process exited before completing request
at Lambda.<anonymous> (/snapshot/repo/dist/index.js:1:1987524)
at Generator.next (<anonymous>)
at fulfilled (/snapshot/repo/dist/index.js:1:1985705)
at process.\_tickCallback (internal/process/next\_tick.js:68:7)

@Weakky
Copy link
Contributor

Weakky commented Apr 15, 2019

Error: Body exceeded 1mb limit

Isn't your issue related to that? vercel/vercel#1127

@williamluke4
Copy link
Author

Yes but this is the error when run locally when deployed the error seems to be different. The Introspection and Playground works when deployed but queries return Only absolute URLs are supported

@swolidity
Copy link

swolidity commented Apr 24, 2019

Not exactly relevant here but because Zeit is moving to serverless with V2 and doesn't exactly fit the GraphQL model right now, I'm going to try moving to Google Cloud Run which is a Serverless Docker offering. A lot like the serverless docker offering that Zeit offered at one point. It might be easier to deploy a Yoga 2 server on there.

@williamluke4
Copy link
Author

@andyk91 Could you let me know how you get on :)

@notrab
Copy link
Contributor

notrab commented Apr 25, 2019

Now + GraphQL are headed in opposite directions and that's ok.

Heroku is a good option for deploying yoga2.

@nezdemkovski
Copy link

nezdemkovski commented Apr 25, 2019

Now + GraphQL are headed in opposite directions and that's ok.

Heroku is a good option for deploying yoga2.

That's not true, why are they heading opposite directions? There is an open issue #14 and the plan is to build yoga with ncc, which makes the whole thing serverless.

@notrab
Copy link
Contributor

notrab commented Apr 25, 2019

@yakovlevyuri I don't get the whole serverless push and then all these monolithic GraphQL servers dotted around. If they can make my resolvers lambdas that would be a great paradigm shift, until then, how's Heroku any different to using @now/node-server?

@DevanB
Copy link
Contributor

DevanB commented Apr 25, 2019

To each their own, and this isn't an issue to discuss who prefers what. This issue is titled "Help: Zeit Now V2 Deployment", not "Let's Discuss Open-endedly About the Future of GraphQL, Serverless, Hosting, and What Provider We Prefer".

In fact, there a more relevant issue for that discussion over at #14. @williamluke4 and I are on a mission to help the Zeit team, and future yoga2 users deploy to Zeit v2. So no need to muck up this issue with your opinions on non-relevant topics.

@notrab
Copy link
Contributor

notrab commented Apr 26, 2019

Hey @DevanB Hold your horses. I've spent the last quarter migrating from Now 1 to 2 and worked with the Zeit team to resolve issues in this space, and for some things (Subscriptions ws) on Now 2 just isn't the right fit. So my experience here kind of tells me Now 2 won't do everything people want moving from 1 to 2 but I certainly didn't mean to say it's not possible! Good luck on your mission! You'll be thanked by many.

@swolidity
Copy link

swolidity commented May 15, 2019

@DevanB not sure if you figured out how to get it working or not but I believe I did and will post here in case anyone else is looking for help.

You can test the api running on now with the following CURL request:

curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ hello(name: \"Andy\") }" }' \
  https://profile-api.andykay.now.sh

You can also see my setup here: https://github.com/andyk91/profile.im . Yoga2 is in /api.

I might not leave yoga2 in my project though so I think the main two pieces are my now.json file:

{
  "version": 2,
  "name": "profile-api",
  "builds": [
    {
      "src": "dist/src/index.js",
      "use": "@now/node-server",
      "config": {
        "maxLambdaSize": "50mb"
      }
    }
  ],
  "routes": [{ "src": "/.*", "dest": "dist/src/index.js" }]
}

and my .nowignore file:

*
!package.json
!dist
!dist/**

@swolidity
Copy link

swolidity commented May 17, 2019

I made another repo dedicated to this issue plus a www folder with nextjs + typescript + apollo here: https://github.com/andyk91/yoga2-serverless

@DevanB
Copy link
Contributor

DevanB commented May 18, 2019

I was able to get my server to deploy by adding introspection: true to the ApolloServer options.

Also, for what it's worth I had to do the same when I created a raw Apollo Server (not using yoga2)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants