Skip to content

tedge-flows service continues to use the old script logic #3978

@rina23q

Description

@rina23q

Describe the bug
tedge-flows service detects the file changes automatically and reloads the scripts.
However, I found a corner case, where tedge-flows still uses an old script path instead of the new one after specific steps.

To Reproduce

Preparation:

a flow test.toml

input.mqtt.topics = ["test/in"]
steps = [
    { script = "test-old.js" },
]

and test-old.js

export function onMessage(message, context) {
    return [{
        topic: "test/out",
        payload: `{"old":"I am from test-old.js"}`
    }]
}

Step to reproduce

  1. Change the script path to test-new.js, which doesn't exist yet.
steps = [
    { script = "test-new.js" },
]
  1. You can confirm the script doesn't exist by tedge flow test test/in ''
$ tedge flows test test/in ''
2026-02-11T13:05:43.574928405Z ERROR flows: Failed to compile flow /etc/tedge/mappers/flows/flows/test.toml: Cannot read file /etc/tedge/mappers/flows/flows/test-new.js: No such file or directory (os error 2)
  1. tedge-flows service still converts the message based on the old test-old.js definition.
[test/in] 
[test/out] {"old":"I am from test-old.js"}
  1. Create test-new.js with this contents.
export function onMessage(message, context) {
    return [{
        topic: "test/out",
        payload: `{"new":"I am from test-new.js"}`
    }]
}
  1. tedge flows test command uses the new script.
$ tedge flows test test/in ''
[test/out] {"new":"I am from test-new.js"}
  1. However, tedge-flows service still uses the old definition.
[test/in] 
[test/out] {"old":"I am from test-old.js"}
  1. To recover this, restart the tedge-flows service. After restart,
[test/in] 
[test/out] {"new":"I am from test-new.js"}

Expected behavior
tedge-flows service uses the new script contents without restarting it.

Screenshots

Environment (please complete the following information):

  • OS [incl. version]
  • Hardware [incl. revision]
  • System-Architecture Linux 2c8819180ed5 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 22:03:50 UTC 2024 aarch64 GNU/Linux
  • thin-edge.io version: tedge 1.7.2~143+g747f913

Additional context
Restarting tedge-flows service resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions