abbr / deasync

Turns async function into sync via JavaScript wrapper of Node event loop
MIT License
971 stars 73 forks source link

Peculiar low level bug with ES6 modules, namely Socket.IO and Express #184

Closed MushyShaman closed 11 months ago

MushyShaman commented 11 months ago

Receiving this error whilst trying to run the example from the main readme.

node: ../deps/uv/src/unix/linux.c:1091: uvpoll_io_uring: Assertion `uvhas_active_reqs(loop)' failed. Aborted (core dumped)

Here is the minimum code to reproduce:

import 'express'; import 'socket.io'; import deasync from 'deasync'; import cp from 'child_process'; console.log(deasync(cp.exec)('ls -la'));

Looking through the other issues I have not been able to find any other reports of this error. Digging around elsewhere, this seems to be coming from some low level C area, but that is beyond me.

It only occurs with ES6 modules, using commonjs' require works fine. It also only occurs when I import both socket.io and express, commenting out either import allows the deasync call to run. Furthermore, not every module causes this. Of those I tested only these 2 cause the bug to occur, which I'd imagine has something to do with their dependencies.

But the plot thickens, if you wrap the deasync call in a setTimeout, even of 0ms, it runs fine. This of course defeats the entire purpose of deasync, but I had a sneaky suspicion this would work and to me it indicates a deeper origin of the issue within Node's execution scheduling.

Environment:

I'm not really expecting a solution that will allow me to use deasync for my project but I thought I'd post this here as it appears to be indicative of a much deeper problem. Love the idea of deasync by the way!

MushyShaman commented 11 months ago

Closing as the issue was duplicated when I changed the title (my bad)