question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using docx@v7.4.0 in Deno will prevent the process from finishing

See original GitHub issue

I’ve been using docx in Deno by importing it from the esm.sh CDN. This is a service that performs some code transformation to serve NPM packages in an ES format. Conveniently it can be used to use just about any NodeJS module in Deno.

So far, docx@7.3.0 has been working like a dream.

Unfortunately, bumping the dependency version to docx@7.4.0 will prevent the process from finishing naturally.

To reproduce:

  1. Install Deno or run it in a Docker container
  2. Create a file test.ts and paste the following contents into it;
    import docx from 'https://esm.sh/docx@7.3.0';
    new docx.Document({
    	sections: [],
    });
    console.log('End of program');
    
  3. Run it as deno run test.ts

nb; using Docker, an easy way to reproduce is to docker run -it --init denoland/deno:ubuntu sh, then echo "import docx from 'https://esm.sh/docx@7.4.0'; new docx.Document({ sections: [] }); console.log('End of program');" > test.ts and deno run test.ts.

Expected

  • The process exits after logging “End of program” to terminal" – which is what happens for the same script in NodeJS, or for the same script but depending on 7.3.0

Observed

  • “End of program” is logged to terminal, and
  • The process never finishes

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
wvbecommented, Jul 8, 2022

Hey @dolanmiu, thanks for spending time on this so promptly. I hope that, beyond the mystery of this bug, it was a pleasant first contact with Deno 😃

Yes, all works well in NodeJS. I’m puzzled wrt what could cause this, intuitively I’m thinking about possibly a stream that is not closed or anything. I couldn’t readily find anything in git diff 7.3.0..7.4.0 that would explain it, but I must admit that I have only scrolled through so far. Since neither of us can readily tell what causes the issue I may spend some of the boss’s time to dive into it again later.

Would you think this issue would be fixed if this module is built as a regular ESM module? This was something I was planning to do, so there shouldn’t be any need for transformations

I have no idea what the bug is, and I’ve not ran into issues before that were caused by esm.sh transformation. Unfortunately I do know that rewriting to ES modules will not magically make it work better in Deno: one of the things that Deno requires is that all imports have the proper file extension – something that NodeJS typescript would actively complain about. Since docx doesn’t do that, some transformation will remain necessary.

nb. For some of my own projects, I (re)write for Deno and use Deno dnt to publish that package for Node as well.

Thanks for your response!

0reactions
dolanmiucommented, Jul 9, 2022

Excellent find!

Thank you so much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deno.exit terminates entire process when using run --watch
I expected Deno.exit to terminate the script, but keep the file watcher ... file:///Users/sidd/code/issue/main.ts Finished Watcher Process ...
Read more >
Introduction | Manual - Deno
Introduction. Deno is a JavaScript, TypeScript, and WebAssembly runtime with secure defaults and a great developer experience. It's built on V8, Rust, ...
Read more >
5 Changes Coming Soon to Deno - Fusebit
Read this blog post and learn the highlight 5 key improvements to Deno in releases in 2022.
Read more >
An Introduction to Deno: Is It Better than Node.js?
json file to keep track of a project's dependencies. Deno does away with those mechanisms in favor of a more browser-centric way of...
Read more >
Bun? Deno? Node.js? Creating your own JavaScript Runtime ...
Bun? Deno ? Node.js? Creating your own JavaScript Runtime using V8, Libuv and more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found