SpreadJS v19 AsyncFunction usage questions

Posted by: srayaprolu on 1 May 2026, 1:10 pm EST

  • Posted 1 May 2026, 1:10 pm EST

    I’m evaluating the performance gains with AsyncFunction from SpreadJS v19 for our custom functions. I am testing with v19.0.6 and plan to migrate our custom calc functions to use calcEngine.asyncFunction.

    I have two questions:

    1. How to reliably access cell information in evaluateAsync? The evaluateAsync method provides an AsyncEvaluateContext parameter, but its public API only documents setAsyncResult. What is the officially supported way to get the sheet, row, and column of the cell being evaluated? I’ve noticed these sometimes appear on an inner object (e.g., context.ctx) with inconsistent naming (col vs column). Is this structure considered stable across minor releases?

    2. Does the context shape change when using CalcWorker? When incrementalCalculation: true is set and the CalcWorker plugin is enabled, does the AsyncEvaluateContext object have a different structure compared to main-thread async evaluation? If so, what is the single recommended access pattern that works consistently in both environments (with and without CalcWorker)?

  • Posted 4 May 2026, 9:45 am EST

    Hi,

    Question 1: Accessing cell info in evaluateAsync

    The

    AsyncEvaluateContext
    object is not a public type. Any inner properties you may have observed (such as
    context.ctx
    ) are internal implementation details.

    As confirmed by the SpreadJS engineering team, the supported approach is to override

    isContextSensitive()
    and return
    true
    (this is the default for async custom functions). When enabled, the context is passed as the first argument to
    evaluateAsync
    , and the following properties are publicly accessible:

    MyFunc.prototype.isContextSensitive = function () {
        return true;
    };
    
    MyFunc.prototype.evaluateAsync = function (context) {
        // perform evaluation (e.g., server call)
        setTimeout(() => {
            console.log("Row:", context.row);
            console.log("Column:", context.col);
            console.log("Sheet:", context.ctx.source.getSheet());
            context.setAsyncResult(Math.random());
        }, 1000);
    };
    

    We have verified this with custom async functions, and the structure remains consistent. If you are observing a different structure, please provide more details so we can investigate further. It would be helpful if you could share a sample that reproduces the issue (or modify the attached sample), along with a GIF or video demonstrating the behavior.


    Question 2: CalcWorker context shape — No change

    This remains unchanged. When CalcWorker is enabled, custom functions are still executed on the UI thread, so the context structure does not differ. The same

    isContextSensitive
    approach works in both scenarios.

    You can refer to the attached sample: https://jscodemine.mescius.io/share/_Xl3JufeYk2ayTbE1aZSLA/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"%2C"%2Fpackage.json"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}

    Regards,

    Priyam

  • Posted 5 May 2026, 9:51 am EST

    sheet property doesnt seem to appear on context obj anymore, it is in context.ctx

  • Posted 6 May 2026, 5:14 am EST

    Hi,

    Could you please provide more details, such as in which version the sheet property was available directly on the context and how it is now appearing under context.ctx?

    Additionally, could you share a sample that replicates this behavior so we can reproduce and investigate it on our end? Alternatively, you may modify the previously shared sample to demonstrate the issue and share the updated with us.

    Regards,

    Priyam

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels