I’m trying to use jsonPath npm package with my Forge project.
const jp = require('jsonpath');
...
const App = () => {
...
console.log(jp.query(json.value,"$.mykey"))
...
}
On deploy I get this error:
Error: Error thrown in the snapshot context.
App code snapshot error: EBADF: bad file descriptor,
Learn more about the snapshot context at https://go.atlassian.com/forge-snapshot-context.
Any ideas?
I’m asking the team involved about this in the mean time you can disable snapshotting with making this false
https://developer.atlassian.com/platform/forge/manifest-reference/#runtime
Docs on our js environment state there are a few Node.js built in modules we don’t support one of which is present at node_modules/jsonpath/lib/aesprim.js
.
var Module = require('module');
If the snapshotting doesn’t work it’s unlikely the runtime will work either.
We are working on alternative solutions around this problem yet to be announced. Until then there isn’t a way around this beyond removing require('module')
.
Switched to
const {JSONPath} = require('jsonpath-plus');
Which seems to work with snapshotting deactivated.
Ok, so not all node-js modules are supported.
What about npm packages? Does that mean certain node-js npm packages are not supported by Forge? Any way to check a package if it’s supported? All this reminds me more and more of OSGi I hope we don’t repeat history here and get a framework that supports all open-source libraries out there.
Hi,
These snapshot errors are not helpful. It doesn’t say which line is causing the snapshot error. In my case, I’m porting a large code base from node to forge runtime, and it is giving a snapshot error saying that it “cannot invoke indexOf undefined”. It doesn’t say which line or file it is. Adding “–verbose” prints nothing helpful in tracing the root of the error. The only way to find this is by commenting out 3rd party dependencies one by one until you fix the error. Once you find the root, you continue the same comment-out approach with dependencies of your dependencies. It takes a lot of time. Is there a flag or something which provides the stack trace of the snapshot error?
My code is also full of console.log
and debugger
statements. Akward. Feels like 1999 PHP times. In terms of Developer experience, it’s essential that line numbers (and yes file names if I need to mention this) are reported precisely. I hope this can be improved in Forge.
2 Likes
Hey everyone,
Sadly we are unable to provide line and column numbers for snapshotting errors due to the underlying APIs in V8. Depending on the error temporarily disabling snapshots might allow you to get more complete debugging information.