Schema script error

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [X] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Minimal reproduction of the problem

I have this content form:

Markets, Countries and Languages are references to other schemas. A market contains id, name and a list of country references and a country contains id, name and a list of language references. Language contains only id and name.

The idea is that when you select some markets and save, the related countries and languages should be checked automatically. The user should also be able to check countries (without markets) and the languages should also check automatically after saving.

This is the schema:

    "properties": {
        "validateOnPublish": false
    },
    "scripts": {
        "create": "if (ctx.data.markets.iv !== null){\r\n    getReferences(ctx.data.markets.iv, callbackcountries);\r\n}\r\nelse if (ctx.data.countries.iv !== null){\r\n    ctx.data.markets.iv = null;\r\n    getReferences(ctx.data.countries.iv, callbacklanguages);\r\n}\r\n\r\nfunction callbackcountries(result){\r\n    var countries = [];\r\n    for (var j = 0; j < result.length;j++){\r\n        for(var i = 0; i < result[j].data.countries.iv.length;i++){\r\n            if (!countries.includes(result[j].data.countries.iv[i])){\r\n                countries.push(result[j].data.countries.iv[i]);\r\n            }\r\n        }\r\n    }\r\n    ctx.data.countries.iv = [];\r\n    ctx.data.countries.iv = countries;\r\n    \r\n    getReferences(countries, callbacklanguages);\r\n}\r\n\r\nfunction callbacklanguages(result){\r\n    if (ctx.data.languageSelection.iv !== 'Custom'){\r\n        var languages = [];\r\n        for (var c = 0; c < result.length;c++){\r\n            for(var d = 0; d < result[c].data.languages.iv.length;d++){\r\n                if (!languages.includes(result[c].data.languages.iv[d])){\r\n                    languages.push(result[c].data.languages.iv[d]);\r\n                }\r\n            }  \r\n        }\r\n        ctx.data.languages.iv = [];\r\n        ctx.data.languages.iv = languages;   \r\n    }\r\n    replace();\r\n}",
        "update": "if (ctx.data.markets.iv !== null){\r\n    getReferences(ctx.data.markets.iv, callbackcountries);\r\n}\r\nelse if (ctx.data.countries.iv !== null){\r\n    ctx.data.markets.iv = null;\r\n    getReferences(ctx.data.countries.iv, callbacklanguages);\r\n}\r\n\r\nfunction callbackcountries(result){\r\n    var countries = [];\r\n    for (var j = 0; j < result.length;j++){\r\n        for(var i = 0; i < result[j].data.countries.iv.length;i++){\r\n            if (!countries.includes(result[j].data.countries.iv[i])){\r\n                countries.push(result[j].data.countries.iv[i]);\r\n            }\r\n        }\r\n    }\r\n    ctx.data.countries.iv = [];\r\n    ctx.data.countries.iv = countries;\r\n    \r\n    getReferences(countries, callbacklanguages);\r\n}\r\n\r\nfunction callbacklanguages(result){\r\n    if (ctx.data.languageSelection.iv !== 'Custom'){\r\n        var languages = [];\r\n        for (var c = 0; c < result.length;c++){\r\n            for(var d = 0; d < result[c].data.languages.iv.length;d++){\r\n                if (!languages.includes(result[c].data.languages.iv[d])){\r\n                    languages.push(result[c].data.languages.iv[d]);\r\n                }\r\n            }  \r\n        }\r\n        ctx.data.languages.iv = [];\r\n        ctx.data.languages.iv = languages;   \r\n    }\r\n    replace();\r\n}",
        "change": ""
    },
    "fieldsInLists": [],
    "fieldsInReferences": [],
    "fields": [
        {
            "name": "name",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "Input",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Unspecified"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "markets",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "Checkboxes",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "0a6f0fd4-ab34-45e9-a634-82fe67c4e296"
                ]
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "countries",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "Checkboxes",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "5c8fddfb-eeed-4bff-8492-abb57b841cd3"
                ]
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "languageSelection",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "Dropdown",
                "inlineEditable": false,
                "isUnique": false,
                "defaultValue": "All selected geography languages",
                "allowedValues": [
                    "All selected geography languages",
                    "Custom"
                ],
                "contentType": "Unspecified",
                "label": "",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "languages",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "Checkboxes",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "92eb8529-17d3-4afe-b9f6-5ff840d5c6c2"
                ]
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        }
    ],
    "isPublished": true
}

The script works perfectly in the first tests I did in cloud to check how Squidex worked, but it doesn’t work in our self hosted environment with Docker. It only fails when we check markets (two getReferences are called), but if we only check countries it works fine. The error says “Failed to create content. Please reload”.

I checked Bug report because I thought it was the most suitable option, but maybe I’m doing something wrong. Do you know where could be the problem?

Thanks a lot!

Environment

  • [X] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [X] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Please check your logs first

Hi Sebastian,

It’s a timeout. I’ll try adjusting the value of TimeoutScript in the JintScriptEngine.

at Jint.Runtime.ExceptionHelper.ThrowTimeoutException()\n at Jint.Constraints.TimeConstraint2.Check()\n at Jint.Engine.RunBeforeExecuteStatementChecks(Statement statement)\n at Jint.Runtime.Interpreter.JintStatementList.Execute()\n at Jint.Runtime.Interpreter.Statements.JintBlockStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.Statements.JintIfStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.JintStatementList.Execute()\n at Jint.Runtime.Interpreter.Statements.JintBlockStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.Statements.JintForStatement.ForBodyEvaluation()\n at Jint.Runtime.Interpreter.Statements.JintForStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.JintStatementList.Execute()\n at Jint.Runtime.Interpreter.Statements.JintBlockStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.Statements.JintForStatement.ForBodyEvaluation()\n at Jint.Runtime.Interpreter.Statements.JintForStatement.ExecuteInternal()\n at Jint.Runtime.Interpreter.JintStatementList.Execute()\n at Jint.Runtime.Interpreter.JintFunctionDefinition.Execute()\n at Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArgument, JsValue[] arguments)\n at lambda_method1418(Closure , JsValue )\n at Squidex.Domain.Apps.Entities.Contents.ReferencesJintExtension.GetReferencesAsync(ExecutionContext context, DomainId appId, ClaimsPrincipal user, JsValue references, Action\u00601 callback) in /src/src/Squidex.Domain.Apps.Entities/Contents/ReferencesJintExtension.cs:line 103\n at Squidex.Domain.Apps.Core.Scripting.JintScriptEngine.TransformAsync(ScriptVars vars, String script, ScriptOptions options) in /src/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs:line 154\n at Squidex.Domain.Apps.Entities.Contents.DomainObject.ContentOperationContext.ExecuteScriptAndTransformAsync(Func\u00602 script, ScriptVars context) in /src/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentOperationContext.cs:line 200\n at Squidex.Domain.Apps.Entities.Contents.DomainObject.ContentDomainObject.CreateCore(CreateContent c) in /src/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs:line 237\n at Squidex.Domain.Apps.Entities.Contents.DomainObject.ContentDomainObject.\u003CExecuteAsync\u003Eb__7_1(CreateContent c) in /src/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs:line 101\n at Squidex.Infrastructure.Commands.DomainObject\u00601.UpsertCoreAsync[TCommand](TCommand command, Func\u00602 handler, Boolean isCreation) in /src/src/Squidex.Infrastructure/Commands/DomainObject.cs:line 214\n at Squidex.Infrastructure.Commands.DomainObjectGrain\u00602.ExecuteAsync(J\u00601 request) in /src/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs:line 47\n at Squidex.Domain.Apps.Entities.Contents.DomainObject.OrleansCodeGenContentGrainMethodInvoker.Invoke(IAddressable grain, InvokeMethodRequest request) in /src/src/Squidex.Domain.Apps.Entities/obj/Release/net5.0/Squidex.Domain.Apps.Entities.orleans.g.cs:line 1358\n at Orleans.Runtime.GrainMethodInvoker.Invoke()\n at Squidex.Infrastructure.Orleans.StateFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/StateFilter.cs:line 51\n at Orleans.Runtime.GrainMethodInvoker.Invoke()\n at Squidex.Infrastructure.Orleans.LocalCacheFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/LocalCacheFilter.cs:line 39\n at Orleans.Runtime.GrainMethodInvoker.Invoke()\n at Orleans.Runtime.GrainMethodInvoker.Invoke()\n at Squidex.Infrastructure.Orleans.ExceptionWrapperFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/ExceptionWrapperFilter.cs:line 35\n at Orleans.Runtime.GrainMethodInvoker.Invoke()\n at Squidex.Infrastructure.Orleans.LoggingFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs:line 46

1 Like