rfennell / AzurePipelines

A single Repo to contain the source for ALL my Azure DevOps Build/Release Extensions. The packages can be found in the Azure DevOps Marketplace
https://marketplace.visualstudio.com/search?term=fenn&target=VSTS&sortBy=Relevance
MIT License
339 stars 429 forks source link

WikiUpdaterTask@2 - Cannot find module 'node:events' #1870

Closed pak-sergey closed 2 months ago

pak-sergey commented 3 months ago

Azure DevOps Extensions

WIKI Updater

Platform

Azure DevOps Services

Azure DevOps Server (TFS) Version

Windows Server 2016 Standard

Extension Version

2.14.4 (3.23.6)

Describe the bug

After 10 April 2024, when WIKI Updater Tasks extension was updated to version 3.23.6, the task started to fail on some environments.

The google search for error: Cannot find module 'node:events', give something about node.js, but node.js is not installed on others environments and it still works, but on some particulars environments it fails with the same script executed.

Please advise.

Repo Steps

steps:

Expected Behavior

No response

Logging Information

Starting: Update Wiki Release notes - 2024-05-01T15:39:48

Task : Git based WIKI Single File Updater from Black Marble Description : A tools to update or create a file in a WIKI based in a Git repo Version : 2.14.4 Author : Richard Fennell Help : Version: #{Build.BuildNumber}#. More Information

[error]Unhandled: Cannot find module 'node:events'

[error]Error: Cannot find module 'node:events'

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at src/lib/plugins/plugin-store.ts (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:1465:26)
at __init (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:26:56)
at src/lib/plugins/index.ts (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:1628:5)
at __init (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:26:56)
at src/lib/git-factory.ts (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:4754:5)
at __init (C:\azagent\A3\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\2.14.4\node_modules\simple-git\dist\cjs\index.js:26:56)

Finishing: Update Wiki Release notes - 2024-05-01T15:39:48

rfennell commented 3 months ago

Can I confirm where you are trying to run this task - is it the AZDO Services (Cloud) or a Server (On premised). If the latter which version of AZDO Server are you using. Also are you using Microsoft Host Build agents or private agents?

I have not experienced with error in either my automated testing, or in any of the pipelines I use which all make use of this task

The change to the code around the 10th Apr was to fix a regression a previous update had cause. You can see the shipped versions and download VSIX for use on on premise AZDO Server instances

pak-sergey commented 3 months ago

It's used on premised Server Windows Server 2016 Standard, it's private agents. It's used on 3 different pipeline and the Task run after deployment on different Servers. From 7 Servers, it fails only on 2 of them. image

The WikiUpdaterTask I believe installed by Pipeline: image

I can try to install latest VSIX, but on 5 others Servers it still works without this step.

rfennell commented 3 months ago

The installation of the VSIX is done automatically by AZDO as part of the running of a pipeline for minor or patch updates (using semver format MAJOR.MINOR.PATCH). So you only have to alter your pipeline to change the major version.

So the question has to be what is the difference in setup on the 2 failing server? Do they have different versions of Node installed?

pak-sergey commented 3 months ago

As it was wrote in description, there is no any Node installed on any of these servers and it still works of 5 others Servers. I agree that 2 failing servers should have something different, but can"t find what it can be. And before last update of the Task, it worked on all of these Servers.

nobba commented 3 months ago

Same problem for us with version 2.14.4. Also on-prem, Azure DevOps Server 2022.0.1.

rfennell commented 3 months ago

Node is installed on an agent when the Azure DevOps agent is installed. The version of Node is dependant on the version of the Azure DevOps agent. If you look your agent's external folder you (amongst other folders) will see some of

image

Is it possible you have different agent versions on different VMs? (Though this seems unlikely as the agent binaries are managed by the Azure DevOps Server)

nobba commented 3 months ago

Ok, I thought that the Task would use any of the node versions available in "..\work\_tool\node" folder? In the externals folder we only have "node" and "node10", so would that perhaps explain the issue in our case?

rfennell commented 3 months ago

In the version of node to be used depends on the task.json file (which you can find in this repo or on a build agent in the <agent>\_work\_tasks\WikiUpdaterTask_e59c5ae6-3afd-479d-bc40-81cd6c541840\<version> folder.

At the end of the file you will find the execution block that defines the Node version to use

For the 3.x WikiUpdater task it contains

"execution": {
      "Node16": {
      "target": "GitWikiTask.js",
      "argumentFormat": ""
    }

For the 2.*

  "instanceNameFormat": "Git based WIKI File Updater",
        "execution": {
                "Node10": {
                        "target": "GitWikiTask.js",
                        "argumentFormat": ""
                }
        }

Note for some tasks there could be multiple execution blocks supporting Node, Node10, Node16 and various PowerShell options - it depends what is packaged in the task

nobba commented 2 months ago

We had an old version of the release pipeline agent, updating that and using latest version of the task worked. Thank you!