Skip to content

Missing constant in axios/lib/adapters/http.js zlibOptions #5888

@scott-knight

Description

@scott-knight

Describe the bug

I'm in the process of upgrading our Rails app (running Rails 6.1) with ESBUILD to compile all js libraries. We have axios being imported through yarn. The issue appears when I upgrade axios to any version greater than 1.2.0. Once the JS is compiled and I load my page, in the browser console, I see this error (Uncaught TypeError: Cannot read properties of undefined (reading 'Z_SYNC_FLUSH'):

Screenshot 2023-09-07 at 10 53 58 AM

To Reproduce

I'm not sure how you would reproduce this error in any setup except mine. I looked online to see if anyone else was seeing this issue and didn't find anything. All I can tell you is that I'm running Rails 6.1, with Ruby 2.7.5, with ESBUILD, jsbunding-rails, etc. JS libraries are installed via yarn 1.22.19. Once ESBUILD compiles, I reload my webpage and this bug appears. If I downgrade to axios version 1.2.0 the bug goes away. If I upgrade to version 1.2.1 or greater, the bug appears.

Code snippet

The bug is coming from here:

// ../../node_modules/axios/lib/adapters/http.js
init_events();
var zlibOptions = {
  flush: exports12.constants.Z_SYNC_FLUSH,
  finishFlush: exports12.constants.Z_SYNC_FLUSH
};

Expected behavior

Should not see an error for a missing constant

Axios Version

>=1.2.1

Adapter Version

http

Browser

Brave

Browser Version

1.57.62

Node.js Version

20.5.1

OS

OSX 13.5.1

Additional Library Versions

├─ @esbuild-plugins/node-resolve@0.2.2
├─ esbuild-plugin-import-glob@0.1.1
├─ esbuild-plugin-polyfill-node@0.3.0
├─ esbuild-rails@1.0.7
├─ esbuild@0.19.2

Additional context/Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions