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

Non response instances are a valid return #60

Closed
janat08 opened this issue Oct 3, 2021 · 4 comments
Closed

Non response instances are a valid return #60

janat08 opened this issue Oct 3, 2021 · 4 comments

Comments

@janat08
Copy link

janat08 commented Oct 3, 2021

I forgot to put my html within a response body using class exported by https://github.com/worker-tools/html and no errors were thrown if you make the request with something like hotwired stimulus.

@mrbbot
Copy link
Contributor

mrbbot commented Oct 4, 2021

Hey! 👋 Are you saying you were able to return an instance of the HTMLResponse class from that library instead of a Response? If so, that should be fine, as the HTMLResponse class extends from Response, so should inherit its behaviour.

@janat08
Copy link
Author

janat08 commented Oct 4, 2021

No I just returned template literal with that library which is why I referenced it, and an error should’ve been thrown because it would in production.

@mrbbot
Copy link
Contributor

mrbbot commented Oct 5, 2021

Ok, I agree there should definitely be an error thrown if the returned response is not a Response. I'm interested that you say "no errors were thrown" though. When I try run this code I get the following error:

import { html } from "@worker-tools/html";

addEventListener("fetch", e => {
  e.respondWith(html`<h1>test</h1>`);
});
[mf:err] GET /: TypeError: Cannot read properties of undefined (reading 'delete')
    at Miniflare._Miniflare_httpRequestListener (.../miniflare/src/index.ts:420:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Is this what you're doing/seeing?

@janat08
Copy link
Author

janat08 commented Oct 5, 2021

I was using worktop so maybe that automatically wraps things in a response, so I simply wasn't able to use the html because there wasn't a content type or something. I suppose that even in miniflare basically trying to send a string along won't a work if it's not instantiated.

@janat08 janat08 closed this as completed Oct 5, 2021
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

2 participants