Skip to content

too many open files in CI environment #609

Description

@MichaelBitard

Describe the bug
On our CI, we get random too many open files errors

Expected behavior
These errors should not appear because we should not be in 'watch' mode?

npx --yes --package=@pgtyped/cli@2.4.3 pgtyped -c pgtyped-config.ci.json
npm warn deprecated no-case@4.0.0: Use `change-case`
npm warn deprecated pascal-case@4.0.0: Use `change-case`
npm warn deprecated camel-case@5.0.0: Use `change-case`
node:internal/fs/watchers:247
    const error = new UVException({
                  ^
Error: EMFILE: too many open files, watch 'pgtyped-config.ci.json'

Our pgtyped config:

{
  "transforms": [
    {
      "mode": "ts",
      "include": "**/*.queries.ts",
      "emitTemplate": "{{dir}}/{{name}}.types.ts"
    }
  ],
  "srcDir": "./src/",
  "failOnError": true,
  "camelCaseColumnNames": false,
  "maxWorkerThreads": 2,
  "db": {
    "host": "dbHost",
    "user": "dbUser",
    "dbName": "dbName",
    "password": "dbPassword"
  },
  "typesOverrides": {
    "oid": "number",
    "geometry": "./src/@types/pg.types.js#PgGeometry"
  }
}

My intuition is that a bug in the --file command makes it scan everything and watch every file in the folder.

For example if I do this command:
npx --yes --package=@pgtyped/cli@2.4.3 pgtyped -c pgtyped-config.ci.json --file src/database/queries/titres-etapes.queries.ts

I get this -->

Using a pool of 2 threads.
Processing src/database/queries/utilisateurs.queries.ts
Processing src/database/queries/titres-utilisateurs.queries.ts
Processing src/database/queries/titres-titres.queries.ts
Processing src/database/queries/titres-etapes.queries.ts
Processing src/database/queries/communes.queries.ts
Processing src/business/processes/titres-public-update.queries.ts
Processing src/business/processes/titres-phases-update.queries.ts
Processing src/business/processes/titres-etapes-mise-en-concurrence.queries.ts
Processing src/business/processes/titres-etapes-heritage-contenu-update.queries.ts
Processing src/business/processes/titres-etapes-consentement.queries.ts
Processing src/api/rest/utilisateurs.queries.ts
Processing src/api/rest/titres.queries.ts
Processing src/api/rest/titre-demande.queries.ts
Processing src/api/rest/quick-access.queries.ts
Processing src/api/rest/perimetre.queries.ts
Processing src/api/rest/mutations.queries.ts
Processing src/api/rest/logs.queries.ts
Processing src/api/rest/journal.queries.ts
Processing src/api/rest/etapes.queries.ts
Processing src/api/rest/entreprises.queries.ts
Processing src/api/rest/entreprises-etablissements.queries.ts
Processing src/api/rest/demarches.queries.ts
Processing src/api/rest/administrations.queries.ts
Processing src/api/rest/activites.queries.ts
Processing src/api/rest/statistiques/metaux-metropole.queries.ts
Processing src/api/rest/statistiques/evolution-titres.queries.ts
Processing src/api/rest/statistiques/dgtm.queries.ts
Processing src/api/rest/statistiques/datagouv.queries.ts
Skipped src/database/queries/titres-utilisateurs.queries.ts: no changes or no queries detected
Skipped src/database/queries/titres-titres.queries.ts: no changes or no queries detected
Skipped src/database/queries/utilisateurs.queries.ts: no changes or no queries detected
Skipped src/database/queries/communes.queries.ts: no changes or no queries detected
Skipped src/business/processes/titres-public-update.queries.ts: no changes or no queries detected
Skipped src/business/processes/titres-phases-update.queries.ts: no changes or no queries detected
Skipped src/business/processes/titres-etapes-mise-en-concurrence.queries.ts: no changes or no queries detected
Skipped src/database/queries/titres-etapes.queries.ts: no changes or no queries detected
Skipped src/business/processes/titres-etapes-heritage-contenu-update.queries.ts: no changes or no queries detected
Skipped src/api/rest/utilisateurs.queries.ts: no changes or no queries detected
Skipped src/business/processes/titres-etapes-consentement.queries.ts: no changes or no queries detected
Skipped src/api/rest/titre-demande.queries.ts: no changes or no queries detected
Skipped src/api/rest/quick-access.queries.ts: no changes or no queries detected
Skipped src/api/rest/titres.queries.ts: no changes or no queries detected
Skipped src/api/rest/mutations.queries.ts: no changes or no queries detected
Skipped src/api/rest/logs.queries.ts: no changes or no queries detected
Skipped src/api/rest/perimetre.queries.ts: no changes or no queries detected
Skipped src/api/rest/journal.queries.ts: no changes or no queries detected
Skipped src/api/rest/etapes.queries.ts: no changes or no queries detected
Skipped src/api/rest/entreprises-etablissements.queries.ts: no changes or no queries detected
Skipped src/api/rest/entreprises.queries.ts: no changes or no queries detected
Skipped src/api/rest/administrations.queries.ts: no changes or no queries detected
Skipped src/api/rest/demarches.queries.ts: no changes or no queries detected
Skipped src/api/rest/statistiques/metaux-metropole.queries.ts: no changes or no queries detected
Skipped src/api/rest/statistiques/evolution-titres.queries.ts: no changes or no queries detected
Skipped src/api/rest/statistiques/dgtm.queries.ts: no changes or no queries detected
Skipped src/api/rest/activites.queries.ts: no changes or no queries detected
Skipped src/api/rest/statistiques/datagouv.queries.ts: no changes or no queries detected
File override specified, but file was not found in provided transforms

It still processes everything, that's strange right?

Maybe that's two completely separate issues though.

Anyway, we run a lot of other CI jobs and that's the only one that does that (we launch a lot of parallel tests with vitest for example) and we only have this problem on this particular command.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions