Skip to content

Unexpected UnhandledPromiseRejectionWarning with Node-API library on Node 12.2.0 on Ubuntu #7621

Closed

Description

@janpio

Only present in 12.2.0 with Node-API library enabled (afaik, double check!)

$ ts-node ./script.ts
(node:1874) UnhandledPromiseRejectionWarning: Error: 
    at /home/runner/work/e2e-tests/e2e-tests/generic/basic/node_modules/@prisma/client/runtime/index.js:22747:77
    at new Promise (<anonymous>)
    at NAPIEngine.start (/home/runner/work/e2e-tests/e2e-tests/generic/basic/node_modules/@prisma/client/runtime/index.js:22744:31)
    at NAPIEngine.request (/home/runner/work/e2e-tests/e2e-tests/generic/basic/node_modules/@prisma/client/runtime/index.js:22815:9)
    at cb (/home/runner/work/e2e-tests/e2e-tests/generic/basic/node_modules/@prisma/client/runtime/index.js:33760:26)
(node:1874) 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: 2)
(node:1874) [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.

via https://github.com/prisma/e2e-tests/runs/2804081663?check_suite_focus=true

Activity

  1. added
    bug/1-unconfirmed
    kind/bug
    tech/typescript
    topic: node-api
    on Jun 11, 2021
  2. janpio commented on Jun 12, 2021

    @janpio
    ContributorAuthor
  3. changed the title [-]Node-API library on Node 12.2.0 on Ubuntu[/-] [+]Unexpected UnhandledPromiseRejectionWarning with Node-API library on Node 12.2.0 on Ubuntu[/+] on Jun 15, 2021
  4. williamluke4 commented on Aug 16, 2021

    @williamluke4

    I've just had a quick look at this. This is the actual error that is causing this

    Error
        at main (/home/will/Prisma/scratch-pad/script.js:24:18)
        at Object.<anonymous> (/home/will/Prisma/scratch-pad/script.js:30:1)
        at Module._compile (internal/modules/cjs/loader.js:776:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
        at Module.load (internal/modules/cjs/loader.js:643:32)
        at Function.Module._load (internal/modules/cjs/loader.js:556:12)
        at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
        at internal/main/run_main_module.js:17:11 {
      code: 'InvalidArg'
    }
    

    It seems that this is a node-api issue. Versions Nodejs v12.0.0 -> 12.5.0 will throw this error but it works from v12.6.0 onwards (This may be related to this PR). Below is a small reproduction

    const  fs = require("fs");
    const QE = require("/home/will/Prisma/scratch-pad/node_modules/.prisma/client/libquery_engine-debian-openssl-1.1.x.so.node");
    
    const datamodel = fs.readFileSync("./prisma/schema.prisma", {
      encoding: "utf8",
    });
    const engine = new QE.QueryEngine(
      {
        datamodel: datamodel,
        env: process.env,
        logQueries: false,
        ignoreEnvVarErrors: false,
        datasourceOverrides: {},
        logLevel: "error",
        configDir: "/home/will/Prisma/scratch-pad/",
      },
      (e, log4) => {
        console.log(e, log4);
      }
    );
    async function main(){
      try {
        await engine.connect({ enableRawQueries: true }) // Throws here
      } catch (e) {
        console.error(e)
      }
      
    }
    main()
  5. added
    bug/2-confirmed
    and removed
    bug/1-unconfirmed
    on Aug 20, 2021
  6. pantharshit00 commented on Aug 20, 2021

    @pantharshit00
    Contributor

    I guess we can bump requirement to 12.6 when we release this to stable.

  7. janpio commented on Aug 20, 2021

    @janpio
    ContributorAuthor

    Will be avoided via #8839

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

Metadata

Metadata

Assignees

Labels

bug/2-confirmedkind/bugtech/typescripttopic: node-api

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions