Skip to content

Unstable Polygon gas station used without fallbacks #5019

@alexanderem49

Description

@alexanderem49

Ethers Version

6.15.0

Search Terms

polygon, plugins, gasstation

Describe the Problem

I've encountered an issue on Polygon Mainnet when getting fees before sending transaction. I initialize AlchemyProvider with own Alchemy key and chain id (as in code snippet below) and the error says that it failed when calling gasstation.polygon.technology which was not configured in my code and surprisingly is hardcoded inside ethers.js library itself. Calling gas station endpoint from multiple servers showed 200 empty response from multiple IPs and regions which for me proves that the endpoint is fragile.

Code Snippet

const provider = new ethers.AlchemyProvider(
	137,
	"<alchemy key>"
);
const feeData = await provider.getFeeData(); // breaks

Contract ABI

Issue does not involve any contract.

Errors

Error: error encountered with polygon gas station ("https://gasstation.polygon.technology/v2") (request=
{}
, response=
{}
, error=
{
    "code": "UNSUPPORTED_OPERATION",
    "info": {
        "response": {}
    },
    "operation": "bodyJson",
    "shortMessage": "response body is not valid JSON"
}
, code=SERVER_ERROR, version=6.14.1)
    at makeError (/var/task/index.js:86543:15)
    at assert (/var/task/index.js:86556:11)
    at FetchUrlFeeDataNetworkPlugin.<anonymous> (/var/task/index.js:101989:7)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _AlchemyProvider.getFeeData (/var/task/index.js:102883:23)
    *** {
  code: 'SERVER_ERROR',
  request: _FetchRequest {},
  response: _FetchResponse {},
  error: Error: response body is not valid JSON (operation="bodyJson", info={ "response": {  } }, code=UNSUPPORTED_OPERATION, version=6.14.1)
      at makeError (/var/task/index.js:86543:15)
      at assert (/var/task/index.js:86556:11)
      at get bodyJson [as bodyJson] (/var/task/index.js:87857:7)
      at FetchUrlFeeDataNetworkPlugin.<anonymous> (/var/task/index.js:101981:32)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async _AlchemyProvider.getFeeData (/var/task/index.js:102883:23)
      *** {
    code: 'UNSUPPORTED_OPERATION',
    operation: 'bodyJson',
    info: { response: _FetchResponse {} },
    shortMessage: 'response body is not valid JSON'
  },
  shortMessage: 'error encountered with polygon gas station ("https://gasstation.polygon.technology/v2")'
}

Environment

node.js (v12 or newer)

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

investigateUnder investigation and may be a bug.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions