JS/TS SDK: node fs compatibility

Gatling version: 3.11.4 (must be up to date)
Gatling flavor: java kotlin scala javascript typescript
Gatling build tool: maven gradle sbt bundle npm

I read the [guidelines] and [how to ask a question] topics.
I provided a [SSCCE] (or at least, all information to help the community understand my topic)
I copied output I observe, and explain what I think should be.

Hello, running demos provided is fine.
But I would like to use some native node function like fs.readFileSync, and I get following errors on run:

const fs = require('fs')
        ╵                    ~~~~

  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.
import fs from 'fs';
         ╵                ~~~~

  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

From graaljs documentation graaljs/graal-nodejs/doc/api/fs.md at master · oracle/graaljs · GitHub, I’ve tried:
const fs = require('node:fs');
But here I get following error message in IDE:
Corresponding file is not included in tsconfig.json

Also, I tried following, but I get same error on run ‘The package “node:fs” wasn’t found on the file system (…)’:
import * as fs from 'node:fs';

What should I do to enable this kind of node functions, or any others?

Thanks

Hi,

Currently, we’re using graal-js, not graal-node.

What are you trying to achieve exactly?

Ok, well concrete use case now is to get some token value from a file feed by a sh script (curl inside, etc.), then to be used in Gatling TS on Post request as authorizationHeader Bearer.

But we will for sure have other needs regarding “basic” node functions or so.
Also, that we would have liked to reuse some common TS code, existing from other projects.

I guess graaljs/docs/user/NodeJSVSJavaScriptContext.md at master · oracle/graaljs · GitHub could be a good start to look at.

Thanks

Why not fetch this token from Gatling instead?

The purpose is to reuse maximum existing TS code from other projects, regarding maintenance, etc.
Because if it’s not possible, there’s less interest to use this new gatling JS/TS SDK, then classical Scala, or even Java is Ok, I guess, for our needs.

Isn’t it possible to make it compatible node fs etc., or plan to be, have you look at github/oracle/graaljs/blob/master/docs/user/Modules.md#experimental-support-for-commonjs-npm-modules-in-the-context-api, maybe the key here?

Thanks

Thanks for your feedback.
That’s something we’ll consider if we collect enough feedback pushing in this direction.

Hi @Nicolas1,

I am the Product Marketing Manager at Gatling. We have a public roadmap for feature development, which allows users to comment on existing features or submit their ideas.

The roadmap helps our Product team prioritize feature development for maximum user benefit. Please consider submitting this idea and any others:

Public Roadmap

Thanks for using Gatling!

Hi Shaun, idea submitted. Which timeline could we expect (optimistic/realistic), depending on how many are interested, internal priorities, etc. I guess?

Thanks

Hi @Nicolas1, Thanks for the submission! I can’t commit to any timeline or if the team will even take up the feature at this early stage.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.