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

Incompatibility of utils.isNode Function with signal-exit in AlaSQL #1889

Closed
Warfront1 opened this issue Feb 22, 2024 · 2 comments · Fixed by #1901
Closed

Incompatibility of utils.isNode Function with signal-exit in AlaSQL #1889

Warfront1 opened this issue Feb 22, 2024 · 2 comments · Fixed by #1901

Comments

@Warfront1
Copy link

Warfront1 commented Feb 22, 2024

An issue has been identified where the utils.isNode function in AlaSQL does not function as expected when used in conjunction with signal-exit.

The issue is in the way that AlaSQL determines if it is running on Node [1][2][3] depends on utils.global.process.reallyExit being untampered with.
It would appear that signal-exit modifies exit and/or reallyExit to the extent that the utils.isNode returns false.
It is highly likely that any other dependency working around/with exit/reallyExit will have a problem with utils.isNode.
I have only isolated this problem with signal-exit, but I would image that there are many other incompatible dependencies.

Here is a complete MRE Dockerfile.

FROM node:16
WORKDIR /test
RUN npm init -y
RUN npm install [email protected] [email protected]
# Create the Node.js script inline
RUN echo "const onExit = require('signal-exit');\n\
onExit(() => console.log('exit'));\n\
const alasql = require('alasql');\n\
const utils = alasql.utils;\n\
console.log('The current value of utils.isNode is: ', utils.isNode);\n\
" > utilsNodeCheck.js
# Run the Node.js script
CMD ["node", "utilsNodeCheck.js"]

As such, any conditional logic based upon utils.isNode is likely to have incorrect behavior.
This issue boils up to problems such as the inability to import files on your local file system likely including CSV, JSON, TAB, IndexedDB, LocalStorage, and SQLite files.
The error message in such a case would typically be the following:
TypeError: Only absolute URLs are supported

@mathiasrw
Copy link
Member

Do you know any better way to detect node?

@vishal6557
Copy link
Contributor

@mathiasrw @Warfront1 I have created the PR; please have a look, and any feedback is appreciated.

mathiasrw pushed a commit that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants