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

Error [ERR_INTERNAL_ASSERTION] #32961

Closed
verberden opened this issue Apr 21, 2020 · 6 comments
Closed

Error [ERR_INTERNAL_ASSERTION] #32961

verberden opened this issue Apr 21, 2020 · 6 comments

Comments

@verberden
Copy link

Hello. So, i was testing my app via Postman and then got error that server doesn't work then go to console and got this error message:

internal/assert.js:14
throw new ERR_INTERNAL_ASSERTION(message);
^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

at assert (internal/assert.js:14:11)
at ServerResponse.detachSocket (_http_server.js:223:3)
at resOnFinish (_http_server.js:684:7)
at ServerResponse.emit (events.js:311:20)
at onFinish (_http_outgoing.js:730:10)
at onCorkedFinish (_stream_writable.js:721:5)
at afterWrite (_stream_writable.js:528:5)
at afterWriteTick (_stream_writable.js:515:10)
at processTicksAndRejections (internal/process/task_queues.js:83:21) {

code: 'ERR_INTERNAL_ASSERTION'
}

I can't reproduse it again. Just open an issue as it says in the error message.

@rickyes
Copy link
Contributor

rickyes commented Apr 21, 2020

Can you provide the code snippets used?

@Puding07
Copy link

I'm getting the same error when trying to run binary file created with nexe. (Just tried Proton-Native). I'm using Pop_OS! 19.10 and Node v12.16.1

@aljones15
Copy link

aljones15 commented May 12, 2020

getting the same issue in nixos version 19 running a test with mocha:

All tests passed.
/project/test/node_modules/mocha/lib/runner.js:873
  throw err;
  ^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at assert (internal/assert.js:14:11)
    at process.target._send (internal/child_process.js:689:5)
    at process.<anonymous> (internal/child_process.js:646:12)
    at process.emit (events.js:323:22)
    at process.EventEmitter.emit (domain.js:482:12)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21) {
  code: 'ERR_INTERNAL_ASSERTION'
}
npm ERR! Test failed.  See above for more details.

I am also getting this error in node 10 and node 12 via github actions which is running inside of a container that is not nixos. Strangely the same test works just fine in mac osx with no issues or errors so it does appear to be an interaction with linux or the mac version does not report the error.
node v12.16.1

the test does use express as a server.

not sure if this was fixed by this commit: f756c809e0

it looks like this is an issue on our side, I will update this comment when I know this for sure.

EDIT: For an future people that get this issue. The problem was a fire and forget style promise that was intentionally not being awaited. Does not seem to be related to node though, issue is with the mocha and the library being tested.

@BridgeAR
Copy link
Member

@verberden the error message alone won't be enough to know if it's an error in Node.js or on your side. The latter is very likely though. It is mostly an error thrown in case some internals are used in unsupported ways. Please check that again and open a new issue if it turns out to be an actual issue with Node.js, thanks!

@vtechguys
Copy link

I came across this error while processing unpaywall research paper data dump and downloading pdf of research papers. I have pruned the database to select the top 100,000 documents and I'm downloading pdfs for those using the following code.

const MongoClient = require("mongodb").MongoClient;
const fetch = require("node-fetch");
const fs = require("fs");

const CONFIG = {
  DB_URI: "mongouri...",
  BATCH_SIZE: 50,
  DB_NAME: 'playground',
  COLLECTION_NAME: 'citations'
};

async function request(id, url) {
  // exist already ignore
  if (fs.existsSync(`./downloads/${id}.pdf`)) {
    return;
  }
  try {
    // try downloading pdf resources
    const response = await fetch(url);
    const fileStream = fs.createWriteStream(
      `./downloads/${id}${
        response.headers.get("content-type") === "application/pdf"
          ? ".pdf"
          : "_unknown.pdf"
      }`
    );
    await new Promise((resolve, reject) => {
      response.body.pipe(fileStream);
      response.body.on("error", reject);
      fileStream.on("finish", resolve);
    });
  } catch (e) {
    fs.appendFileSync(
      "errors.json",
      `, ${JSON.stringify({ id, url, error: e.message })} \n`
    );
  }
}

// connect mongo and start downloading doc
MongoClient.connect(CONFIG.DB_URI, async function (err, client) {
  if (err) {
    console.error(err);
    return;
  }
  // make sure dir exist
  if (!fs.existsSync("./downloads")) {
    fs.mkdirSync("./downloads");
  }
  // db
  const db = client.db(CONFIG.DB_NAME);
  const collection = db.collection(CONFIG.COLLECTION_NAME);
  // make sure mongo session cursor timeour doesn't happen
  const docs = collection.find().addCursorFlag("noCursorTimeout", true);
  // download file for each doc
  try {
    const totalDocuments = await docs.count();
    let batchCount = 0;
    // batch
    let requestPromises = [];
    // loop over doc cursor
    while (await docs.hasNext()) {
      const { url_for_pdf: url, _id: id } = await docs.next();
      if (id && url) {
        try {
          // put doc in batch
          requestPromises.push(() => request(id, url));
          // check if reached batch size...then process batch
          if (requestPromises.length === CONFIG.BATCH_SIZE) {
            // wait for download of this batch
            await Promise.all(requestPromises.map(r=>r()));
            batchCount += CONFIG.BATCH_SIZE;
            requestPromises = [];
          }
        } catch (e) {
          console.log("Error 1", e.message);
        }
      }
    }

    console.log("Batch processed: " + batchCount + "/" + totalDocuments);
  } catch (e) {
    console.log("Error 2" + e.message);
  } finally {
    client.close();
  }
});

Screenshot from 2021-05-28 19-59-36

This has happened several times and every time the script fails after downloading 10k-13k docs.

@jfoclpf
Copy link

jfoclpf commented Feb 1, 2024

Anyone can tell me what most likely causes this error? On my side it seems lottery, sometimes it fails, others it doesn't

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

No branches or pull requests

7 participants