-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Using const or let in global scope have problem in nodejs actions #1728
Comments
@bjustin-ibm might be good to look into this one. It most be something todo with on how we use |
FWIW, this is "documented" here:
|
I'm confused - my main was a function. It is as well in the code above. |
@psuter It's not very clear the statement just said that |
I think this is a limitation that we would end documenting, but first would like to understand the root cause on why behaves this way. |
Sorry, I read your example too quickly. You have indeed demonstrated a more general instance of the problem than the one I wrote about in the blog post: any top-level |
I never really super fan this I proposed we look into writing the file int tmpfs (i.e. memory) and then do a clean I think it's important to fix this, as I can see a lot people using We would need to tell folks to make a migration some how that user will need to OR we could try to eval, catch the exception, and then do the |
Someone bumped into this issue and when I was asked for help, I was confused by the error as well. The example was a top-level |
shouldn't we be doing the module wrappering at creation time? why wrapper it on every invocation? we already support zip actions, and these impose an "action-as-module" requirement. so, to start with, the (another point against eval: it obfuscates stack traces) |
Good idea @starpit but I would hold on doing something in the CLI just yet. I think for now, we update the nodejs proxy code, to take the string, append Then have the cli help building the zip, and would be also good to store the zip as an attachment in the DB which @rabbah said that's the direction. One crazy idea was to save the action as two attachments one for the node_modules content and a second one for anything outside, this will allow something like a Web App UI and CLI be very efficient to retrieve the source code in a browser UI and ignore the node_modules. |
I submitted PR #1929 to address this issue. It uses a function scope as opposed to a module to bypass the filesystem (avoid the temporary file). |
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
…nodejs actions (apache#1929)
Creating an action with variables declare in the global scope using
const
orlet
then accessing this variables inside the
main
produce errors.Bug found by user @cfjedimaster:
Here is an example to reproduce:
changing to use
var
then it worksRunning as a zip action it doesn't have this problem, but running as a simple file (i.e. eval) it has this problem.
Produce the following error
The text was updated successfully, but these errors were encountered: