Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error fetching Function Core Tools releases: Cannot find download package for Windows (POSSIBLE FIX INCLUDED) #899

Open
rondonjon opened this issue Dec 13, 2024 · 0 comments

Comments

@rondonjon
Copy link
Contributor

rondonjon commented Dec 13, 2024

Are you accessing the CLI from the default port :4280 ?

n/a

Make sure you are accessing the URL printed in the console when running swa start!

n/a

Describe the bug

npx swa start fails in Windows because static-web-apps-cli can't find an appropriate version of the Azure Function Core Tools to download.

To Reproduce

Steps to reproduce the behavior:

  1. Ensure you have no previously downloaded version of the Azure Function Core Tools downloaded and cached (~/.swa/core-tools/v4/func)
  2. Type in command 'swa start'

Expected behavior

SWA should find and download an appropriate version of the Azure Function Core Tools.

Desktop (please complete the following information):

  • OS: Windows 11
  • Node version: 22
  • CFT target version: 4

Additional context

The problems seems to be caused by a filter condition in func-core-tools.js that matches for none of the distributions in the latest release.

After fetching the release list from https://functionscdn.azureedge.net/public/cli-feed-v4.json , the code resolves the latest v4 release in the tags section of the feed (currently 4.104.0), locates the corresponding entry in the releases section of the feed, and then attempts to find a distribution in that release for the platform ("Windows") with size "full".

const coreTools = release.coreTools.filter((t) => t.size === "full");

As it turns out, there is no such distribution in the 4.104.0 release, nor has there been a distribution that matches both criteria after 4.88.0. Later releases do have Windows distributions, but all of them have size "minified".

Sadly the code exits with an exception at this point, leaving Windows users without a previous download with a broken tool chain.

I don't know the CFT package well enough to understand if the "minified" distribution might be usable and the evaluation could be extended to include it.

As a safer alternative, I would suggest to find the newest release that has a distribution which matches all criteria, as follows:

  • remove the resolution of the "latest" release in the "tags" section
  • find all entries in the "releases" section that have:
    • a key starting with ${targetVersion}. <-- filter by major release
    • a distribution that has the correct platform and "full" size
  • pick the last matching entry (currently safe because the array is properly sorted) or (better) sort by semver and pick the latest matching release by version number

(update)
Pull request #900

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant