-
Notifications
You must be signed in to change notification settings - Fork 11
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
Bad "fn is not a function" error when methods are in the code #811
Comments
Awesome work on kit. @josephjclark Be more robust in the runtimewouldn't it be a bit more tricky to try catching the error? given that there are several other errors that bubble up to that point. eg. How about just checking whether Still doesn't seem to solve the problem of it not being a function that returns state but at least makes sure that we have a function. Catch the issue in the compilerYup, semantic analysis may take a very long time to achieve. How about instead of waiting till runtime to catch the function error described above. Would it be better to catch this at compile time? because we reach here first. Making sure that Assuming all the top level code are from imports.If all top-level Nodes at eg. import { fn } from "@openfn/language-common"
fn(state=> state) // assuming users always use defined funcs
// assuming no use does any of the below at the top-level
(state) => state;
console.log("smth");
... // things that aren't from adaptors What are your thoughts? |
Hi @doc-han - are you looking for some interesting work in the compiler or runtime? I'm sure I can find a good ticket for you :) |
Alright, sounds cool. looking forward to the tickets.
|
@doc-han I'll get back to you tomorrow - not at my desk today! |
Hey @doc-han , it would be great to keep your eyes on this and one closely related problem next.
Yes, happy with this. I think you have to check it's a function OR a promise 🤔 That should quickly become obvious when you check the code.
I've been meaning to address this forever - see #737 Ok, it's not a very good issue. But if any operation fails to return a state object (and this happens all the time actually!) we should console.log a really loud warning and set state to
Yes, we could probably do this! But at the moment I'm not keen on a compiler fix because our main app, Lightning, doesn't actually show compiler logs. So the users who need it most wouldn't get the warning. We'll leave the compiler alone for now - although if you're particularly interested in the compiler I do think I have some useful issues you could look at. |
The error comes out of the runtime. It has nothing to do with common.fn - it's just trying to invoke an argument called
fn
. It's a confusing variable name, basically.Maybe we should fix that, but the bigger story here is that the compiler needs to behave better in this case.
Or maybe the runtime does?
Basically because
console.log
isn't an operation, it doesn't return a function, and so it breaks the execution pipeline.Options:
The text was updated successfully, but these errors were encountered: