Skip to content

Works once...then not again? And jumps me to other parts of my code? #107

Answered by mceachen
dave-linsalata asked this question in Q&A
Discussion options

You must be logged in to vote

If nothing is being output to console, I suspect the main loop is not awaiting your promise chain, so node thinks it can ignore it and exit.

Both of the following examples work as expected on Node 16.13.1:

A more readable async/await style:

const exiftool = require("exiftool-vendored").exiftool;

async function run() {
  const tags = await exiftool.read("../../examples/tiny.jpg");
  console.log(tags);
  await exiftool.end();
  console.log("finished.")
}

void run();

And promise .then chains:

const exiftool = require("exiftool-vendored").exiftool;

void exiftool
  .read("../../examples/tiny.jpg")
  .then(console.log)
  .then(() => exiftool.end())
  .then(() => console.log("finished!"));

Th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dave-linsalata
Comment options

Answer selected by mceachen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants