Git Product home page Git Product logo

Comments (5)

yusukebe avatar yusukebe commented on June 3, 2024

Hi @Code-Hex

Which version of @hono/vite-dev-server are you using?

from vite-plugins.

Code-Hex avatar Code-Hex commented on June 3, 2024

I'm using 0.8.0. I am also investigating.

I'm sorry, I made a mistake in the order of describing the issues in the ticket. Actually, the error occurs due to the following problem.

The error in the title of this issue occurs when the following code is commented out.

* If the response is not instance of `Response`, throw it so that it can be handled
* by our custom errorHandler and passed through to Vite
*/
if (!(response instanceof Response)) {
throw response
}

There are two issues. The one I initially wrote and the Internal server error: Unknown error: [object Response] issue. The issue I wrote initially occurs after resolving the Unknown error: [object Response]' problem.

I also suspect that the fetch client being called within app.fetch is the cause. The object returned by this client is a Response object, but it is not captured by the instanceof part, resulting in an error. I added lines:

if (!(response instanceof Response)) {
    console.log(new Response(null, 200), response)
    throw response;
}

and below is the output it generates.

_Response [Response] {} Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: true,
    requestIncludesCredentials: true,
    type: 'default',
    status: 200,
    timingInfo: {
      startTime: 3204.850082397461,
      redirectStartTime: 0,
      redirectEndTime: 0,
      postRedirectStartTime: 3204.850082397461,
      finalServiceWorkerStartTime: 0,
      finalNetworkResponseStartTime: 0,
      finalNetworkRequestStartTime: 0,
      endTime: 0,
      encodedBodySize: 435,
      decodedBodySize: 435,
      finalConnectionTimingInfo: null
    },
    cacheState: '',
    statusText: 'OK',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [ URL {} ],
    body: { stream: undefined }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(7) {
      'date' => [Object],
      'content-type' => [Object],
      'content-length' => [Object],
      'connection' => [Object],
      'server' => [Object],
      'access-control-allow-origin' => [Object],
      'access-control-allow-credentials' => [Object]
    },
    [Symbol(headers map sorted)]: null
  }
}
Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: true,
    requestIncludesCredentials: true,
    type: 'default',
    status: 200,
    timingInfo: {
      startTime: 3204.850082397461,
      redirectStartTime: 0,
      redirectEndTime: 0,
      postRedirectStartTime: 3204.850082397461,
      finalServiceWorkerStartTime: 0,
      finalNetworkResponseStartTime: 0,
      finalNetworkRequestStartTime: 0,
      endTime: 0,
      encodedBodySize: 435,
      decodedBodySize: 435,
      finalConnectionTimingInfo: null
    },
    cacheState: '',
    statusText: 'OK',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [ URL {} ],
    body: { stream: undefined }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(7) {
      'date' => [Object],
      'content-type' => [Object],
      'content-length' => [Object],
      'connection' => [Object],
      'server' => [Object],
      'access-control-allow-origin' => [Object],
      'access-control-allow-credentials' => [Object]
    },
    [Symbol(headers map sorted)]: null
  }
}

I think this is similar issue: nodejs/undici#2358

I confirmed this code works fine! (but there seems to be a better way 😇 )

if (!isResponse(response)) {
    throw response;
}

function isResponse(v: any): v is Response {
    return ["Response", "_Response"].includes(response.constructor.name)
}

from vite-plugins.

yusukebe avatar yusukebe commented on June 3, 2024

Hi @Code-Hex

Thanks for investigating!

I confirmed this code works fine! (but there seems to be a better way 😇 )

I think it's not bad. But I'll find other good ways.

from vite-plugins.

yusukebe avatar yusukebe commented on June 3, 2024

Hi @Code-Hex

Does this issue still happen? I've tried it with the latest @hono/vite-dev-server, v0.11.0, it works well. Can you try it again?

from vite-plugins.

Code-Hex avatar Code-Hex commented on June 3, 2024

@yusukebe Thanks for your confirmation!
I have not been able to confirm this, but if the issue comes up again, I will open it and close it for now!

from vite-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.