vmware-labs / wasm-workers-server

🚀 Develop and run serverless applications on WebAssembly

Home Page:https://workers.wasmlabs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Angelmmiguel opened this issue · comments

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

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.