prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Prisma deploy Error: Token is issued in the future (iat)

Open BiscuiTech opened this issue 7 years ago • 11 comments

Describe the bug On execution of prisma deploy, the CLI responds with Error: Token is issued in the future (iat).

To Reproduce Steps to reproduce the behavior:

  1. Execute prisma deploy

Expected behavior The expected behavior would be to correctly deploy the schema to the hosted DB, and execute the post-deploy script to get the generated schema.

Screenshots Here is the full error logs with DEBUG="*" on prisma deploy

deploy checking if project exists +0ms
  client Sending query to cluster default +0ms
  client https://api.my-website.com/management +0ms
  client 
  client       query($name: String! $stage: String!) {
  client         project(name: $name stage: $stage) {
  client           name
  client           stage
  client         }
  client       }
  client      +1ms
  client { name: 'charmant', stage: 'dev' } +1ms
  deploy adding project +270ms

Creating stage dev for service charmant...  client Sending query to cluster default +268ms
  client https://api.my-website.com/management +1ms
  client       mutation addProject($name: String! $stage: String! $secrets: [String!]) {
  client         addProject(input: {
  client           name: $name,
  client           stage: $stage
  client           secrets: $secrets
  client         }) {
  client           project {
  client             name
  client           }
  client         }
  client       }
  client        +0ms
  client { name: 'charmant',
  client   stage: 'dev',
  client   secrets: [ 'REDACTED' ] } +2ms
 !
Error: Token is issued in the future (iat).: {"response":{"data":{"addProject":null},"errors":[{"locations":[{"line":2,"column":9}],"path":["addProject"],"code":3015,"message":"Token is issued in the future (iat).","requestId":"local:cjsexk4sk000x07413n4kkgb8"}],"status":200},"request":{"query":"      mutation addProject($name: String! $stage: String! $secrets: [String!]) {\n        addProject(input: {\n          name: $name,\n          stage: $stage\n          secrets: $secrets\n        }) {\n
 project {\n            name\n          }\n        }\n      }\n      ","variables":{"name":"charmant","stage":"dev","secrets":["REDACTED"]}}}
    at GraphQLClient.<anonymous> (C:\Users\jchuet\AppData\Roaming\npm\node_modules\prisma\node_modules\graphql-request\src\index.ts:72:13)
    at step (C:\Users\jchuet\AppData\Roaming\npm\node_modules\prisma\node_modules\graphql-request\dist\src\index.js:40:23)
    at Object.next (C:\Users\jchuet\AppData\Roaming\npm\node_modules\prisma\node_modules\graphql-request\dist\src\index.js:21:53)
    at fulfilled (C:\Users\jchuet\AppData\Roaming\npm\node_modules\prisma\node_modules\graphql-request\dist\src\index.js:12:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
Exiting with code: 1

Versions (please complete the following information):

  • Connector: PostgreSQL
  • Prisma Server: 1.27
  • prisma CLI: 1.27 & 1.28
  • OS: Win10 and the Hosted setup runs on DigitalOcean Managed DBs.
  • other dependencies: not applicable. this only concerns the deploy method of the CLI

Additional context I had some issues correctly configuring the PostgreSQL side (since we are not given superuser on the new DO Managed DBs platform), so the issue could stem from this side. I just have a hard figuring out what exactly does this error entail.

Here is my setup: DB SIDE - on DigitalOcean DB config.yml

port: 4466
managementApiSecret: REDACTED
databases:
  default:
    connector: postgres
    host: REDACTED.db.ondigitalocean.com
    database: charmant-glouton
    user: prisma-charmant
    password: REDACTED
    schema: charmant-glouton
    rawAccess: true
    port: '25060'
    migrations: true
    ssl: true

dockerfile

FROM prismagraphql/prisma:1.27
ARG PRISMA_CONFIG_PATH
ENV PRISMA_CONFIG_PATH prisma.yml
COPY config.yml prisma.yml
EXPOSE 4466

BACKEND SIDE prisma.yml

endpoint: ${env:PRISMA_ENDPOINT_DEV}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
hooks:
  post-deploy:
    - graphql get-schema -p prisma

.graphqlconfig.yml

projects:
  app:
    schemaPath: "src/schema.graphql"
    extensions:
      endpoints:
        default: "http://localhost:4444"
  prisma:
    schemaPath: "src/generated/prisma.graphql"
    extensions:
      prisma: prisma.yml

BiscuiTech avatar Feb 21 '19 18:02 BiscuiTech

@BiscuiTech Can you please check your server's system time?

Also, please check your own machine's system time. It looks like somehow iat is exceeding the current time in the server.

pantharshit00 avatar Feb 21 '19 18:02 pantharshit00

Thanks for the quick reply.

On my own machine - local dev (where prisma deploy is executed): Thursday, February 21, 2019 1:33:55 PM

On the hosted prisma server: Thu Feb 21 13:33:52 EST 2019

On the DB: "2019-02-21 13:33:57.889423-05"

Please disregard the seconds as I had to manually switch windows to excute those commands.

BiscuiTech avatar Feb 21 '19 18:02 BiscuiTech

Time looks good. cc @mavilein any idea here?

pantharshit00 avatar Feb 21 '19 18:02 pantharshit00

I have fixed this issue by changing my internet time provider to gov on my dev machine.

I realized there was a slight 8 seconds delay between my local dev and the hosted server. Although very slim, it caused an iat error.

Thanks for the insight @pantharshit00 .

BiscuiTech avatar Feb 21 '19 20:02 BiscuiTech

I also encountered the issue and had to use another time server on my development machine. Shouldn't this be fixed?

ameistad avatar Mar 01 '19 21:03 ameistad

Same for me. This is kind of annoying, I can't doing anything on my development machine.

kieusonlam avatar Mar 06 '19 10:03 kieusonlam

I am closing this. This is more related to a specific machine's time so we really can't do a fix for this. Anyone facing this will need to manually adjust their machine's time

Please open a new issue if you think strongly that this is bug in Prisma ecosystem and shouldn't be closed

pantharshit00 avatar Apr 03 '19 14:04 pantharshit00

I was able to fix this issue by restarting my docker machine. It seems like there should be some sort of network time synchronization built into the nodes though, as it's fairly common for different system clocks to be off by a few seconds. Older windows machines can be off by minutes.

zwhitchcox avatar May 10 '19 18:05 zwhitchcox

If you are on macOS, just uncheck and check set date and time automatically in time settings. Worked for me.

scientist1642 avatar Aug 17 '19 06:08 scientist1642

You can also run the following command in macOS to sync time

sudo sntp -sS time.apple.com

pantharshit00 avatar Aug 23 '19 10:08 pantharshit00

hello fellas, since we have this problem and clock synchronization solutions you propose do not cut it, I have opened Feature request issue #4878 , where I propose the possible feature which would solve this problem, which is very easy to implement. Please leave your comment or thumbs up within the issue, so that I know if my idea is correct.

simonobe avatar Sep 12 '19 13:09 simonobe