amp-toolbox icon indicating copy to clipboard operation
amp-toolbox copied to clipboard

Runtime version getting timeout

Open c0b41 opened this issue 6 years ago • 12 comments

my nextjs application using optimizer but last 24 hours getting runtime version timeout error, also this happen before 3-4 months ago maybe google cloud outages happen latelty.

so we need some fallback version for runtime-version

https://github.com/ampproject/amp-toolbox/blob/master/packages/runtime-version/lib/RuntimeVersion.js#L76-L86

update:

{ FetchError: request to https://cdn.ampproject.org/rtv/metadata failed, reason: connect ETIMEDOUT 216.58.206.193:443
    at ClientRequest.<anonymous> (/usr/src/node_modules/node-fetch/lib/index.js:1455:11)
    at ClientRequest.emit (events.js:198:13)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  message:
   'request to https://cdn.ampproject.org/rtv/metadata failed, reason: connect ETIMEDOUT 216.58.206.193:443',
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT' }

c0b41 avatar Mar 18 '20 11:03 c0b41

I haven't heard of any google cloud outages. Did this happen in prod?

But we definitely should have some kind of fallback. This is also a DevX problem as development is hindered while offline.

My suggestion would be:

  1. download and cache the latest runtime version + v0.css on install.
  2. fallback to cached version on time out (500ms?)
  3. update cached version on every successful download

sebastianbenz avatar Mar 18 '20 12:03 sebastianbenz

@sebastianbenz this happen in production.

c0b41 avatar Mar 18 '20 13:03 c0b41

@sebastianbenz also we can't controll this behavior see https://github.com/zeit/next.js/blob/2ba352da39ee00b6595aecdc9ffb2f103e803a85/packages/next/next-server/server/optimize-amp.ts#L9

c0b41 avatar Mar 18 '20 13:03 c0b41

Thanks for the details. This was most likely an issue in your prod environment. The runtime version is served from the same endpoint as the AMP runtime which had no outages. Nevertheless, we should fix optimizer falling because of this.

Sidenote: it's going to be possible to configure optimizer in Next.js once https://github.com/zeit/next.js/pull/10705 has landed in prod.

sebastianbenz avatar Mar 18 '20 18:03 sebastianbenz

@sebastianbenz thanks again maybe my server had some issue, either way following next pull request

c0b41 avatar Mar 18 '20 19:03 c0b41

I'm getting the same issue when using the optimizer to build from my dev machine...

FetchError: request to https://cdn.ampproject.org/rtv/metadata failed, reason: read ECONNRESET at ClientRequest. at ClientRequest.emit (events.js:210:5) at TLSSocket.socketErrorListener (_http_client.js:406:9) at TLSSocket.emit (events.js:210:5) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:80:21) { message: 'request to https://cdn.ampproject.org/rtv/metadata failed, reason: read ECONNRESET', type: 'system', errno: 'ECONNRESET', code: 'ECONNRESET' } (node:28732) UnhandledPromiseRejectionWarning: FetchError: request to https://cdn.ampproject.org/rtv/metadata failed, reason: read ECONNRESET at ClientRequest. (C:\Users\rajd9\repos\bhajanlyrics\node_modules\node-fetch\lib\index.js:1455:11) at ClientRequest.emit (events.js:210:5) at TLSSocket.socketErrorListener (_http_client.js:406:9) at TLSSocket.emit (events.js:210:5) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:80:21) (node:28732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:28732) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

rajd90 avatar Apr 12 '20 13:04 rajd90

I'm having the same issue in production from time to time with my NextJS App, unfortunately this results in an Internal server error even if the user is not navigating an AMP page. Anyone found a workaround or a solution for this?

mirkodrummer avatar Apr 23 '20 14:04 mirkodrummer

Yeah, I'm also seeing this issue in production. Curious if anyone found a workaround to the 502 in production

stanleycyang avatar Jun 28 '20 07:06 stanleycyang

I fixed it by porting over all my code to a new nextjs project and redeploying it. Sucks, but it seemed to have worked.

stanleycyang avatar Jun 28 '20 16:06 stanleycyang

The fix is already in the latest Next.js canary. Would be great if someone could verify this.

sebastianbenz avatar Jun 29 '20 08:06 sebastianbenz

I'm not using Next.js but had the same error in my server using amp-optimizer-express. The error seems to be fixed by #747. Thanks for opening this issue and fixing it.

herablog avatar Jul 21 '20 08:07 herablog

any update on how to solve this problem?

luiznasciment0 avatar Nov 12 '20 18:11 luiznasciment0