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

Add example with Miniflare/Wrangler2 #54

Closed
justinnoel opened this issue Jan 19, 2022 · 10 comments
Closed

Add example with Miniflare/Wrangler2 #54

justinnoel opened this issue Jan 19, 2022 · 10 comments

Comments

@justinnoel
Copy link
Contributor

justinnoel commented Jan 19, 2022

I'd love to see an official example with Miniflare with live reloading for development mode.

I've put together my own project that was working with Miniflare 2.0.0 and Hono 0.0.13. However, if I update Miniflare to 2.2.0, it no longer works. Miniflare shows this on the durable object example:

[mf:err] GET /api/: TypeError: Failed to parse URL from [object Object]
    at new Request (/Users/jn/Apps/project-api/node_modules/undici/lib/fetch/request.js:83:23)
    at new Request (/Users/jn/Apps/project-api/node_modules/miniflare/node_modules/@miniflare/core/src/standards/http.ts:398:13)
    at EventTarget.dispatchFetch (/Users/jn/Apps/project-api/node_modules/miniflare/node_modules/@miniflare/core/src/index.ts:999:51)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Server.<anonymous> (/Users/jn/Apps/project-api/node_modules/@miniflare/http-server/src/index.ts:167:20)
@justinnoel
Copy link
Contributor Author

Actually, maybe not necessarily Miniflare but the new Wrangler2 wrangler@beta?

@justinnoel justinnoel changed the title Add example with Miniflare Add example with Miniflare/Wrangler2 Jan 19, 2022
@yusukebe
Copy link
Member

Hi @justinnoel

I've tried a Durable Object example with Miniflare 2.2.0. It worked correctly.
Example is here: https://github.com/yusukebe/hono/tree/master/example/durable-objects
This code is based on the official example. It might be well if you use latest version of Hono. If it does not work, let's think about it together.

@justinnoel
Copy link
Contributor Author

Thanks for the response. That's the sample I was using.

On previous versions of Hono with Miniflare 2.2.0, I was getting the error above. Now, with Hono 0.0.16, it's all resolved 🎉!

So, something in #55 probably fixed this issue.

Thanks again!

@MatteoGauthier
Copy link

Got the same ▲ [WARNING] Failed to get worker definitions TypeError: fetch failed issue with Workers KV on the 3.1.0 version

@yusukebe
Copy link
Member

Hi @MatteoGauthier !

Could you provide some snippets to reproduce the problem?

I've tried to run the simple application using KV with v3.1.0. It works well.

import { Hono } from 'hono'

type Bindings = {
  FOO: KVNamespace
}

const app = new Hono<{ Bindings: Bindings }>()

app.get('/', async (c) => {
  await c.env.FOO.put('name', 'Hono')
  const val = await c.env.FOO.get('name')
  return c.text(`Hello ${val}`)
})

export default app

@MatteoGauthier
Copy link

Hi @MatteoGauthier !

Could you provide some snippets to reproduce the problem?

I've tried to run the simple application using KV with v3.1.0. It works well.

import { Hono } from 'hono'

type Bindings = {
  FOO: KVNamespace
}

const app = new Hono<{ Bindings: Bindings }>()

app.get('/', async (c) => {
  await c.env.FOO.put('name', 'Hono')
  const val = await c.env.FOO.get('name')
  return c.text(`Hello ${val}`)
})

export default app

Oh sorry, here is a reproduction repository for the issue : https://github.com/MatteoGauthier/hono-fetch-issue-kv

@yusukebe
Copy link
Member

Thanks! I'll try it.

@yusukebe
Copy link
Member

@MatteoGauthier

I've tried your repo, but it works fine.

I did:

  1. Clone the repo.
  2. yarn install
  3. yarn dev
  4. Run curl command

SS

You get an error when you start up Wrangler with the --local option, right?

@MatteoGauthier
Copy link

@yusukebe Yes exactly with --local (tested with latest wrangler version)

@yusukebe
Copy link
Member

I see. But I can't seem to reproduce the issue. Hmm.

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

No branches or pull requests

3 participants