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

Runtime version getting timeout #650

Open
c0b41 opened this issue Mar 18, 2020 · 12 comments · May be fixed by southernTrbl/amp-toolbox#4 or southernTrbl/amp-toolbox#64
Open

Runtime version getting timeout #650

c0b41 opened this issue Mar 18, 2020 · 12 comments · May be fixed by southernTrbl/amp-toolbox#4 or southernTrbl/amp-toolbox#64

Comments

@c0b41
Copy link

c0b41 commented Mar 18, 2020

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' }
@sebastianbenz
Copy link
Collaborator

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

@c0b41
Copy link
Author

c0b41 commented Mar 18, 2020

@sebastianbenz this happen in production.

@c0b41
Copy link
Author

c0b41 commented Mar 18, 2020

@sebastianbenz
Copy link
Collaborator

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 vercel/next.js#10705 has landed in prod.

@c0b41
Copy link
Author

c0b41 commented Mar 18, 2020

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

@rajd90
Copy link

rajd90 commented Apr 12, 2020

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.

@mirkodrummer
Copy link

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?

sebastianbenz added a commit that referenced this issue Apr 28, 2020
This PR extracts fetching and configuration of runtime parameters into a
separate function outside the transformers. This externalizes and
centralizes runtime parameter handling enabling, removing the
responsibility of handling runtime configuration inside transformers
(with the potential for duplication) and enabling future optimizations
of file system based caching of runtime artifacts (see #650).
sebastianbenz added a commit that referenced this issue Apr 28, 2020
This PR extracts fetching and configuration of runtime parameters into a
separate function outside the transformers. This externalizes and
centralizes runtime parameter handling enabling, removing the
responsibility of handling runtime configuration inside transformers
(with the potential for duplication) and enabling future optimizations
of file system based caching of runtime artifacts (see #650).
sebastianbenz added a commit that referenced this issue May 4, 2020
* pass validator rules object via params

* Extract RuntimeParameters

This PR extracts fetching and configuration of runtime parameters into a
separate function outside the transformers. This externalizes and
centralizes runtime parameter handling enabling, removing the
responsibility of handling runtime configuration inside transformers
(with the potential for duplication) and enabling future optimizations
of file system based caching of runtime artifacts (see #650).

* update to amp.dev

* use 15 digit version numbers

* update jsdoc
@stanleycyang
Copy link

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

@stanleycyang
Copy link

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

@sebastianbenz
Copy link
Collaborator

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

@herablog
Copy link

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.

@luiznasciment0
Copy link

any update on how to solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants