Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Analyze step in kit post-build not reporting api methods correctly #10984

Closed
ethanjdiamond opened this issue Nov 5, 2023 · 0 comments · Fixed by #11019
Closed

Analyze step in kit post-build not reporting api methods correctly #10984

ethanjdiamond opened this issue Nov 5, 2023 · 0 comments · Fixed by #11019
Labels
bug Something isn't working

Comments

@ethanjdiamond
Copy link

Describe the bug

The analyze.js file at kit/src/core/postbuild is not populating any of the api methods of routes. This means the builder in the adapt method of adapters are getting incorrect metadata about routes.

The incorrect block of code is here (link):

Object.values(mod).forEach((/** @type {import('types').HttpMethod} */ method) => {
	if (mod[method] && ENDPOINT_METHODS.has(method)) {
		api_methods.push(method);
	} else if (mod.fallback) {
		api_methods.push('*');
	}
});

mod is going to have GET as the key, and the function as the value, but the foreach is being run on Object.values(mod) instead of Object.keys(mod). This means that the method variable is a function instead of the name of the HTTP action and mod[method] && ENDPOINT_METHODS.has(method) will always evaluate to false. Object.values needs to be Object.keys.

Reproduction

  1. Create a route that's got a +server.ts in it that exports just a GET function
  2. Put a console.log(JSON.stringify(builder)) in the adapt method of an adapter.
  3. Observe the routes in the output of the builder log does not have 'GET' in methods or api.methods

Logs

No response

System Info

System:
    OS: macOS 14.0
    CPU: (12) arm64 Apple M2 Pro
    Memory: 124.86 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm
    pnpm: 8.7.6 - ~/Library/pnpm/pnpm
    bun: 1.0.2 - /usr/local/bin/bun
  Browsers:
    Chrome: 119.0.6045.105
    Safari: 17.0
  npmPackages:
    svelte: ^4.2.2 => 4.2.2 
    vite: ^4.5.0 => 4.5.0

Severity

serious, but I can work around it

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants