Gatling version: 3.13.401
Gatling flavor: javascript
Gatling build tool: npm
Hello, I’m learning on gatling-js for team need, with this sample script
// required for Gatling core structure DSL
import { scenario, simulation, ElFileBody, exec, atOnceUsers } from "@gatling.io/core";
// required for Gatling HTTP DSL
import { http, status } from "@gatling.io/http";
export default simulation((setUp) => {
const ClientBulkReportingHigh = exec(
http('ClientBulkReportingHigh')
.post('URL')
.header('Content-Type', 'application/json')
.body(ElFileBody('jsonFile.json'))
.check(status().is(200))
.requestTimeout(300000)
);
const UserBehavior = scenario('Users')
.exec(ClientBulkReportingHigh);
setUp(
UserBehavior
.injectOpen(atOnceUsers(1)),
);
});
I got this error, while the computerdatabase simulation doesn’t get it:
Bundling a Gatling simulation with options:
- sourcesFolder: src
- bundleFile: target/bundle.js
- typescript: false
Running a Gatling simulation with options:
- simulation: ClientBulkReportingSimulation
- bundleFile: target/bundle.js
- resourcesFolder: resources
- resultsFolder: target/gatling
15:30:30.134 [ERROR] i.g.a.Gatling$ - Run crashed
org.graalvm.polyglot.PolyglotException: TypeError: undefined is not a function
at <js>.:=>(bundle.js:2892)
at <js>.:program(bundle.js:1)
at org.graalvm.polyglot.Context.eval(Context.java:402)
at io.gatling.js.JsSimulationHelper.loadSimulation(JsSimulationHelper.java:64)
at io.gatling.js.JsSimulation.<init>(JsSimulation.java:38)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 9 common frames omitted
Wrapped by: java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:501)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:485)
at io.gatling.app.SimulationClass$JavaScript.params(SimulationClass.scala:57)
at io.gatling.app.Runner.load(Runner.scala:72)
at io.gatling.app.Runner.run(Runner.scala:55)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
at io.gatling.app.Gatling$.main(Gatling.scala:40)
at io.gatling.app.Gatling.main(Gatling.scala)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:501)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:485)
at io.gatling.app.SimulationClass$JavaScript.params(SimulationClass.scala:57)
at io.gatling.app.Runner.load(Runner.scala:72)
at io.gatling.app.Runner.run(Runner.scala:55)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
at io.gatling.app.Gatling$.main(Gatling.scala:40)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: org.graalvm.polyglot.PolyglotException: TypeError: undefined is not a function
at <js>.:=>(bundle.js:2892)
at <js>.:program(bundle.js:1)
at org.graalvm.polyglot.Context.eval(Context.java:402)
at io.gatling.js.JsSimulationHelper.loadSimulation(JsSimulationHelper.java:64)
at io.gatling.js.JsSimulation.<init>(JsSimulation.java:38)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 9 more
C:\projects\gatling-js-demo-main\javascript\node_modules\@gatling.io\cli\target\java.js:33
reject(Error("Gatling process finished with code " + code));
^
Error: Gatling process finished with code 1
at ChildProcess.<anonymous> (C:\projects\gatling-js-demo-main\javascript\node_modules\@gatling.io\cli\target\java.js:33:24)
at ChildProcess.emit (node:events:524:28)
at maybeClose (node:internal/child_process:1101:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5)
Node.js v22.13.1
The log was not “friendly” to me to understand what exactly happened here, it would be helpful if I can get some insights, thank you.
Edit: My project source tree:
resources
->jsonFile.json
src
->ClientBulkReportSimulation.gatling.js
Other leave as default.