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

The JavaScript kit returns a wrong result when using Hono's html helper #238

Closed
Angelmmiguel opened this issue Oct 18, 2023 · 1 comment · Fixed by #239
Closed

The JavaScript kit returns a wrong result when using Hono's html helper #238

Angelmmiguel opened this issue Oct 18, 2023 · 1 comment · Fixed by #239
Assignees
Labels
🐛 bug Something isn't working 🔨 sdks Issues related to language SDKs
Milestone

Comments

@Angelmmiguel
Copy link
Contributor

Describe the bug

I developed an application that uses the html helper from Hono. The original code is the following one (before bundling it with esbuild):

import { Hono } from 'hono'
import { html } from 'hono/html'

const app = new Hono()

app.get('/:username', (c) => {
  const { username } = c.req.param()
  return c.html(
    html`<!DOCTYPE html>
      <h1>Hello! ${username}!</h1>`
  );
})

export default app;

Wasm Workers Server returns an "error running the function" message.

Reproduction steps

  1. Create a new folder

  2. Create an index.js file with the content above

  3. Bundle it with esbuild:

    npx esbuild index.js --format=esm --bundle --outfile=dist/[...app].js
    
  4. Run the current main branch of the project and pass the dist folder as an argument:

    cargo run -- ../PATH_TO_HONO_PROJECT_FOLDER/dist
    
  5. Try to access http://localhost:8080/hi

Expected behavior

The following application returns a correct HTML code instead of an error.

Additional context

No response

@Angelmmiguel Angelmmiguel added 🐛 bug Something isn't working 🔨 sdks Issues related to language SDKs labels Oct 18, 2023
@Angelmmiguel Angelmmiguel added this to the 1.7.0 milestone Oct 18, 2023
@Angelmmiguel Angelmmiguel self-assigned this Oct 18, 2023
@Angelmmiguel
Copy link
Contributor Author

The error comes from the Response type in the JS kit shims. Currently, we store the body parameter as it is regardless of the type. We assumed this variable would be always a string. However, Hono is returning an String object, which is slightly different than string primitives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🔨 sdks Issues related to language SDKs
Projects
None yet
1 participant