Visual Studio Code 和 Azure Functions 继续在本地运行旧代码(MacOS、Node.js)

问题描述 投票:0回答:1

在“users”数组中,有近千个实体。我在本地运行代码(运行和调试)并在某个时候取消了它。如果我尝试再次运行甚至评论代码:

var tasks = [];
for (const userEmail of users) {
    var task = context.df.callSubOrchestrator('MainMailingSendToUserOrchestrator', { userEmail });
    tasks.push(task);
}
yield context.df.Task.all(tasks);

然后,无论函数内部有什么代码,子协调器都会继续运行。

如何清理缓存或修复该问题?

launch.json:

{
   "name": "Mailing",
   "type": "node",
   "request": "attach",
   "port": 9230,
   "preLaunchTask": "func: host start"
}
node.js visual-studio-code azure-functions
1个回答
0
投票

检查以下步骤以清除 Visual Studio Code 中持久函数的缓存:

在tasks.json中添加命令

json "command": "${command:workbench.action.clearEditorHistory}"
。感谢@Ishtiaque Khan的命令。

.vscode/tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "func",
            "label": "func: host start",
            "command": "host start",
            "problemMatcher": "$func-node-watch",
            "isBackground": true,
            "dependsOn": "npm install (functions)"
        },
        {
            "type": "shell",
            "label": "npm install (functions)",
            "command": "npm install"
        },
        {
            "type": "shell",
            "label": "npm prune (functions)",
            "command": "npm prune --production",
            "problemMatcher": []
        },
        {
            "label": "clear-editor-history",
      "command": "${command:workbench.action.clearEditorHistory}"
        }
    ]
}

launch.json:

{
    "configurations": [
        {
        ...
            "preLaunchTask": "clear-editor-history"
        ...
        }
    ]
}

或者您可以通过以下步骤清除缓存:

  1. 在 Visual Studio Code 中打开命令面板(Cmd + Shift + P)
  2. 输入命令清除搜索历史记录=>Enter
  3. 输入命令清除编辑器历史记录=> Enter

enter image description here

本地

Azurite storage emulator
可能有编排器和活动函数的旧条目,请清除Azure存储模拟器的缓存。

在命令面板中搜索

Azurite:Clean
=>输入。

enter image description here

清除缓存后重新启动 VS Code 以应用更改。

请参阅文章了解清除缓存的其他方法。

在进行多个测试运行时,旧的编排历史记录可能会导致混乱。如果之前的编排仍在进行中或留下了一些残留状态,则清除历史记录将删除它并允许重新开始。

使用 Azure Core Tools 命令清除编排状态

func durable purge-history
,请参阅 SO

© www.soinside.com 2019 - 2024. All rights reserved.