Skip to content

Deferred function arguments change over time #704

Closed
@Ghostbird

Description

@Ghostbird

I'm stuck with a rather strange situation.
I have to asynchronously retry some CLR functions that are called from Jint, while ensuring their calling order is maintained.
Therefore, I defer such Func<JsValue, JsValue[], JsValue>s to a queue that tries the deferred function until it succeeds, and then continues with the next one.
The problem happens when I do something like this:

// JavaScript
MyCLRFunctionRefWithRetry('foo');
MyCLRFunctionRefWithRetry('bar');

Both functions are called, deferred and after 30 seconds the first is retried. At this point args[0] of the deferred function call MyCLRFunctionRefWithRetry('foo'); resolves to 'bar' instead of 'foo'.
Note that a lot of other stuff is going on around these function calls too, and they are not really called immediately after each other in the Jint engine.

Annoyingly I cannot reproduce this behaviour in my minimal-code example: https://github.com/Ghostbird/JintAsyncRetry

Could someone shed some light on why this happens? Maybe even suggest an avenue to fix it?
I've tried to integrate argument serialisation before deferring and de-serialisation on execution, however too much runtime type information is lost and the app goes down in a shower of InvalidCastExceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions