Last 12 weeks · 3 commits
1 of 6 standards met
Closes #369. Summary replace the native constructor identity check with a structural check for the response interface consumed by the Node.js adapter keep forwarding invalid application return values to Vite's error handler add an end-to-end regression test using from add a patch changeset This allows Fetch API-compatible implementations such as the response returned by GraphQL Yoga to work without requiring applications to recreate them with Node.js's global constructor. The existing check was introduced in #45 to reject invalid return values such as strings, and #63 later routed those values through Vite's error handler. This change preserves that behavior while replacing constructor identity with an interface check, so compatible Response implementations are not treated as application errors. Tests
Description rejects Fetch API-compatible objects when they were created by a different implementation than Node.js's global constructor. The dev server currently checks the response with: This makes constructor identity part of the contract. A response from , for example, exposes the standard response fields and methods but is not an instance of Node.js's built-in class. The plugin therefore forwards a successful HTTP response to Vite's error handler, which renders an error such as: This occurs in practice with GraphQL Yoga, which can return through / . Minimal reproduction Start Vite and request . The application returns a valid response, but the dev server reports it as an unknown error. Expected behavior The dev server should accept Fetch API-compatible responses from other implementations. If requires a native Node.js , the plugin can normalize a compatible response into one while preserving its body, status, status text, and headers. Invalid return values should continue to reach Vite's error handler as they do today. Environment : 0.26.1 : 0.9.0 Node.js: reproducible on supported Node.js versions with built-in Fetch API support
After submitting a regular HTML form the body appears empty on the Hono endpoint. The content type arrives as expected but the body is completely empty: I'm guessing something happens with the body with Vite's dev server? Not sure if this is out of scope for though. If not maybe a note should be added to the README.
When using with Deno, requests for pre-bundled client dependencies (from ) hit the Hono router instead of being served by Vite, resulting in 404s for all of them. I have been able to reproduce it here: https://github.com/vhespanha/hono-vite-deno-repro. Run it and you'll see the bundled dep requests ( in this case) hitting the router. This behavior is not present in Node. I think the root cause is that is not present on the exclude list. But for whatever reason NodeJS doesn't care about that and works anyways. I have been able to fix it by simply doing: But I'm also gonna be opening a PR to include the directories to the aforementioned exclude list.
Repository: honojs/vite-plugins. Description: Vite Plugins for Hono Stars: 292, Forks: 64. Primary language: TypeScript. Languages: TypeScript (99.8%), JavaScript (0.2%). Homepage: https://hono.dev Latest release: @hono/vite-dev-server@0.26.1 (2mo ago). Open PRs: 7, open issues: 27. Last activity: 2mo ago. Community health: 25%. Top contributors: yusukebe, github-actions[bot], 3w36zj6, arisris, meck93, ryuapp, berlysia, chadxz, Moshyfawn, calebkish and others.