"yarn: not found" in Google App Engine Standard Environment

813 Views Asked by At

I am migrating an existing GAE Flex application to GAE Standard, and the app won't start. The gcloud app deploy command succeeds, but the webserver process fails on calls to yarn:

[start] 2021/04/23 16:40:57.592718 No entrypoint specified, using default entrypoint: /serve
[start] 2021/04/23 16:40:57.596207 Starting app
[start] 2021/04/23 16:40:57.596522 Executing: /bin/sh -c exec /serve
[start] 2021/04/23 16:40:57.602799 Waiting for network connection open. Subject:"app/invalid" Address:127.0.0.1:8080
[start] 2021/04/23 16:40:57.603189 Waiting for network connection open. Subject:"app/valid" Address:127.0.0.1:8081
[serve] 2021/04/23 16:40:57.616964 Serve started.
[serve] 2021/04/23 16:40:57.617857 Args: {runtimeLanguage:nodejs runtimeName:nodejs14 memoryMB:256 positional:[]}
[serve] 2021/04/23 16:40:57.620632 Running /bin/sh -c DEBUG=express:*,typeorm:* yarn ts-node:run src/index.ts
sh: 1: yarn: not found
[start] 2021/04/23 16:40:57.628730 Start program failed: failed to detect app after start: ForAppStart(): [aborted, context canceled. subject:"app/valid" Timeout:30m0s, attempts:4 aborted, context canceled. subject:"app/invalid" Timeout:30m0s, attempts:5]
Container called exit(1). 

It seems that yarn is picked up and works just fine on the build step, but not in the runtime. Cloudbuild logs contain a bunch of lines similar to this one:

Step #7 - "exporter": Reusing layer 'google.nodejs.yarn:env' 

The app.yaml is minimal:

runtime: nodejs14
service: /* redacted */

resources:
  cpu: 2
  memory_gb: 2

includes:
  - env_variables.production.yaml

#[START cloudsql_settings]
beta_settings:
  cloud_sql_instances: /* redacted */
#[END cloudsql_settings]

And the package.json looks roughly like this:

{
  "engines": {
    "node": ">=14"
  },
  ...,
  "scripts": {
    "start": "DEBUG=express:*,typeorm:* yarn ts-node:run src/index.ts",
    "ts-node:run": "ts-node -r tsconfig-paths/register -r dotenv/config"
  }
}

What are my possible workarounds here? I'd like to avoid switching to npm because a bunch of package scripts rely on yarn already, and it would take time to ensure that the change won't affect them.

Searching the GCP github for a solution, I came across a similar issue in the ruby-docker image. It could well be a temporary bug on the GCP side.

0

There are 0 best solutions below