Skip to content

The duplex member must be specified for a request with a streaming body #1729

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

Closed
1 task done
kevinhikaruevans opened this issue Jun 24, 2024 · 1 comment
Closed
1 task done
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@kevinhikaruevans
Copy link

Description

This is my first time seeing this issue after using this library for a while. But I've noticed that when I do a POST to an endpoint, like:

client.POST('/api/dsr/rows/validate', {
     body: {action: 'Move', action_data: 'a', bot_id: 1, step: 1, status: 'NotStarted', uuid: '1'}
})

It raises this error:

openapi-fetch.js?v=53b3da91:100 Uncaught (in promise) 
TypeError: Failed to execute 'fetch' on 'Window': The `duplex` member must be specified for a request with a streaming body
    at coreFetch (openapi-fetch.js?v=53b3da91:100:26)
    at Object.POST (openapi-fetch.js?v=53b3da91:147:14)
    at DSRGrid (DSRGrid.tsx:47:12)
    at renderWithHooks (chunk-YDDRBQTN.js?v=53b3da91:11548:26)
    at updateFunctionComponent (chunk-YDDRBQTN.js?v=53b3da91:14587:32)

...which seems odd, considering I'm just passing in a simple object. I'm also doing a couple GETs and those work just fine.

Reproduction

This seems to only happen in Chrome. I'm using Version 125.0.6422.141 (Official Build) (64-bit). In Firefox (127.0.1 (64-bit)) this works as expected. I've also tried using a bodySerializer w/ JSON.stringify-ing the object.

I'm using FastAPI as the backend using a simple endpoint that basically does nothing:

    @router.post('/rows/validate')
    def validate_row(row: Row) -> Row:
        return row

Note that this endpoint doesn't actually get hit by the client. It's failing before the request is sent. The relevant OpenAPI stuff looks like this:

    "/api/dsr/rows/validate": {
      "post": {
        "summary": "Validate Row",
        "operationId": "validate_row_api_dsr_rows_validate_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Row-Input"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Row-Output"
                }
              }
            }
          },
          "404": {
            "description": "not found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }

with Row-Input looking like:

      "Row-Input": {
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid4",
            "title": "Uuid"
          },
          "step": {
            "type": "integer",
            "title": "Step"
          },
          "bot_id": {
            "type": "integer",
            "title": "Bot Id"
          },
          "action": {
            "type": "string",
            "enum": [
              "Move",
              "etc..."
            ],
            "title": "Action"
          },
          "action_data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Coord"
              },
              {
                "items": {
                  "$ref": "#/components/schemas/DispenseData"
                },
                "type": "array"
              },
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Action Data"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "NotStarted",
                  "InProgress",
                  "Done"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status",
            "default": "NotStarted"
          }
        },
        "type": "object",
        "required": [
          "step",
          "bot_id",
          "action",
          "action_data"
        ],
        "title": "Row"
      },

Expected result

It should do a POST

Checklist

I can do a PR if I can figure out what is happening.

@kevinhikaruevans kevinhikaruevans added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Jun 24, 2024
@drwpow
Copy link
Contributor

drwpow commented Jun 24, 2024

Duplicate of #1715. This has been resolved in 0.10.0.

@drwpow drwpow closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

No branches or pull requests

2 participants