apache / apache/couchdb-nano

Error under electron: Adapter 'http' is not available in the build

Open
#332 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
689
Forks
167
Avg merge
1h
Merged PRs (30d)
1

Description

## Expected Behavior
Used nano without errors under Node 20.4.0. I want to use the exactly same code under Electron that bundles Node 18.16.1

## Current Behavior
At the first call to nano
```
import Nano from "nano";
const nano = Nano({url: "my-CouchDB-url", requestDefaults: {timeout: 120_000}});
const databaseList = await nano.db.list();
```
I receive the error:
```
Adapter 'http' is not available in the build
```
Seems the error is generated by `axios` and seems the solution is to move to `fetch`. There is a possible workaround at https://github.com/axios/axios/issues/5523 but setting `agent` in the `requestDefaults` has no effect.

## Possible Solution
1) scrap axios and use fetch :-)
2) document a way to change axios adapter from outside. Agent option seems that does not change anything.

## Steps to Reproduce (for bugs)

1. Create an Electron application
2. In the main.js (that is, the Node process) add the lines listed above (putting a known CouchDB url).
3. Run `npm run dev`
4. See the error

## Context
Well, this problem blocks entirely my porting of the client-server application under Electron.
If there is no solution I have to scrap CouchDB and move to another DB.

## Your Environment

* Version used: 10.1.2
* Browser Name and version: Electron 26.0.0 that runs Node 18.16.1. Not run in browser.
* Operating System and version (desktop or mobile): Windows 11 64bits desktop
* Link to your project: Not public

Contributor guide

Open the contributing guide

Research direction

Start with the Electron application's main.js and reproduce the failure by running npm run dev with the shown Nano configuration and a known CouchDB URL. Read how Nano passes requestDefaults to axios, including the adapter and agent behavior mentioned in the issue; done means nano.db.list() works under Electron 26 without the unavailable http adapter error.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript, node.js
Domain
api, backend, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.