slackapi / node-slack-sdk

Slack Developer Kit for Node.js
https://slack.dev/node-slack-sdk
MIT License
3.27k stars 660 forks source link

The 'credentials' field on 'RequestInitializerDict' is not implemented. #1868

Open emersonlaurentino opened 1 month ago

emersonlaurentino commented 1 month ago

I'm using hono, bun and cloudflare wrangler, I'm getting this error when I use web-api.

AxiosError: The 'credentials' field on 'RequestInitializerDict' is not implemented.

Packages:

Select all that apply:

Reproducible in:

The Slack SDK version

    "@slack/web-api": "^7.3.1",

Node.js runtime version

node: v20.12.0
bun: 1.1.22

OS info

roductName:            macOS
ProductVersion:         14.6
BuildVersion:           23G80
Darwin Kernel Version 23.6.0: Fri Jul  5 17:56:41 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T6000

Steps to reproduce:

Any request is giving this error, examples of requests I'm using:

Expected result:

Just work!

Actual result:

Screenshot 2024-08-08 at 12 37 39

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. :bow:

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

hello-ashleyintech commented 1 month ago

Hi, @emersonlaurentino! Thanks for your question! 🙌

Based on the error, this seems like an issue with the Cloudflare Workers SDK. I found this related issue here. The good news is, since it looks like you're using Axios, someone release a PR for a fix for this issue for Axios ~1 hour ago!

In the meantime, while that's getting reviewed, merged, and released, someone suggested this approach:

on the server-side i just check if credentials are supported and set them to undefined if not

const isCredentialsSupported = "credentials" in Request.prototype; 
fetch("...", { credentials: isCredentialsSupported ? "include" : undefined })

maybe try the above and see if it works with your use case?

seratch commented 3 weeks ago

@emersonlaurentino Even after resolving this specific error, you'll encounter more errors with Bun and Cloudflare Workers because this project focuses on Node.js runtime use cases. I understand you prefer first-party tools, but I created third-party libraries to build your Slack apps on edge function platforms. Please consider using the alternative solution this time. See https://github.com/slackapi/node-slack-sdk/issues/1603#issuecomment-1606541205 for more details.