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

Error in parsing response body #1461

Open
kobofare opened this issue Sep 2, 2024 · 5 comments
Open

Error in parsing response body #1461

kobofare opened this issue Sep 2, 2024 · 5 comments

Comments

@kobofare
Copy link

kobofare commented Sep 2, 2024

Use jdsom and vitest to write unit tests. sends a grpc request to the envoy proxy. When the number of bytes returned is less than 16k, it can be returned correctly. Otherwise, the error "Error in parsing response body" will be reported.
jsdom:25.0.0
vitest:2.0.5
grpc-web:1.5.0
google-protobuf:3.21.4

@kobofare
Copy link
Author

kobofare commented Sep 2, 2024

[2024-09-01T09:05:54.537Z] "OPTIONS /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 0 0 0 - "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "457182f3-5644-4481-8edc-140c9fc14832" "-"
[2024-09-01T09:05:54.540Z] "POST /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 296 9188 25 [::1]:9101 "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "f641121d-4ea8-4ff5-87dc-7a3fc3cfabb2" "24"
[2024-09-01T13:53:16.535Z] "OPTIONS /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 0 0 11 - "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "56a24680-bde8-48a1-95d8-0ca80bc490d0" "-"
[2024-09-01T13:53:16.555Z] "POST /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 296 16583 183 [::1]:9101 "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "11df149f-95a5-4df2-ac3e-7461b689c106" "163"

@kobofare
Copy link
Author

kobofare commented Sep 2, 2024

[2024-09-01T09:05:54.537Z] "OPTIONS /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 0 0 0 - "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "457182f3-5644-4481-8edc-140c9fc14832" "-" [2024-09-01T09:05:54.540Z] "POST /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 296 9188 25 [::1]:9101 "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "f641121d-4ea8-4ff5-87dc-7a3fc3cfabb2" "24" [2024-09-01T13:53:16.535Z] "OPTIONS /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 0 0 11 - "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "56a24680-bde8-48a1-95d8-0ca80bc490d0" "-" [2024-09-01T13:53:16.555Z] "POST /yeying.api.identity.Identity/Search HTTP/1.1" 200 - 296 16583 183 [::1]:9101 "-" "Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/25.0.0" "11df149f-95a5-4df2-ac3e-7461b689c106" "163"

In Envoy's log, when 9188 bytes are returned, the test case does not report an error. When 16583 bytes are returned, an error is reported.

@github-staff github-staff deleted a comment from kobofare Sep 3, 2024
@sampajano
Copy link
Collaborator

@kobofare Hi, thanks for the report!

I'm wondering if you could share some code snippets and your test setup configs (e.g. maybe with docker as well), so it could help us understand the issue?

Are you talking to a real grpc server behind envoy?

It's rather difficult for me to make out what exactly is going on from the log you provided :)

@kobofare
Copy link
Author

kobofare commented Sep 18, 2024

yes, a real grpc server, this is a vitest config:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    globals: true,
    environment: "jsdom",
  },
})

@kobofare
Copy link
Author

kobofare commented Sep 18, 2024

js client code:


export class AssetProvider {
  constructor(authenticate, provider) {
    this.authenticate = authenticate
    this.provider = provider
    this.client = new AssetClient(this.provider.extend.proxy)
  }

  search(format, page, pageSize) {
    return new Promise(async (resolve, reject) => {
      const method = '/yeying.api.asset.Asset/Search'
      const body = new SearchRequestBody()
      body.setFormat(typeof format === 'string' ? convertDigitalFormatFrom(format) : format)
      body.setPage(page)
      body.setPagesize(pageSize)

      let header
      try {
        header = await this.authenticate.createHeader(method, body)
      } catch (err) {
        console.error('Fail to create header for searching asset', err)
        return reject(err)
      }

      const request = new SearchRequest()
      request.setHeader(header)
      request.setBody(body)

      this.client.search(request, undefined, (err, res) => {
        this.doSearchResponse(method, err, res, resolve, reject)
      })
    })
  }
}

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
@sampajano @kobofare and others