Skip to content

Conversation

@rjd15372
Copy link
Member

The scripting engine runtime has a fake client that can be used to call commands inside the scripts, and is re-used throughout the scripting engine life cycle.

The VM_Call implementation uses a temporary client from a client cache to run a command, but when running VM_Call in the context of a script, we don't need to get a temporary client from the cache, and can use the scripting engine client that was already prepared to run the command by the scriptPrepareForRun() function in script.c.

This commit makes this small change in VM_Call to use the scripting engine client instead of a temporary client from the client cache.

The scripting engine runtime has a fake client that can be used to call
commands inside the scripts, and is re-used throughout the scripting
engine life cycle.

The `VM_Call` implementation uses a temporary client from a client cache
to run a command, but when running `VM_Call` in the context of a script,
we don't need to get a temporary client from the cache, and can use the
scripting engine client that was already prepared to run the command by
the `scriptPrepareForRun()` function in `script.c`.

This commit makes this small change in `VM_Call` to use the scripting
engine client instead of a temporary client from the client cache.

Signed-off-by: Ricardo Dias <[email protected]>
@rjd15372 rjd15372 requested a review from zuiderkwast November 11, 2025 11:44
@rjd15372 rjd15372 self-assigned this Nov 11, 2025
@rjd15372
Copy link
Member Author

@zuiderkwast this is the last PR before opening the PR that moves the Lua engine into its own external module.

@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.41%. Comparing base (331a852) to head (34ca4c6).

Files with missing lines Patch % Lines
src/module.c 0.00% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #2826      +/-   ##
============================================
- Coverage     72.42%   72.41%   -0.02%     
============================================
  Files           128      128              
  Lines         70366    70369       +3     
============================================
- Hits          50961    50956       -5     
- Misses        19405    19413       +8     
Files with missing lines Coverage Δ
src/module.c 9.76% <0.00%> (-0.01%) ⬇️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Ricardo Dias <[email protected]>
@rjd15372
Copy link
Member Author

@zuiderkwast this is the last PR before opening the PR that moves the Lua engine into its own external module.

Ups, I had to open another 😄 #2835

/* When running a script the context client is already a fake client
* prepared for running a command on behalf of the real client.
* This preparation is done by the scriptPrepareForRun() in script.c */
c = scriptGetClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reusing the client, the clients have different flags. Are we sure that this is correct?

The scripting engine client has:

    c->flag.deny_blocking = 1;
    c->flag.script = 1;
    c->flag.fake = 1;

But the module client has:

        c->flag.module = 1;
        c->flag.fake = 1;

Assuming that we want to make the flags change, what are the future maintainability implications? If the scripting engine later makes changes to its client, it needs to be compatible with modules reusing it. Does this create an unnecessary coupling?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripting engine client will only be used by VM_Call when the VM_Call is called during the execution of a script.

If for some reason we need to update the scripting engine client flags, we can do that in a backward compatible way because we have access to the API version used by the scripting engine module.

@rjd15372
Copy link
Member Author

the failed tests are not related to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants