hotwired / stimulus

A modest JavaScript framework for the HTML you already have

Home Page:https://stimulus.hotwired.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conflicting Fetch between stimulus and Hotwire

jdpy19 opened this issue · comments

Hey! I have spun up a new project this morning and I am running into an issue that is due to window.fetch being overridden with the fetch in set operations.

export function fetch<K, V>(map: Map<K, Set<V>>, key: K): Set<V> {

Hotwire is using window.fetch which should be the native
https://github.com/hotwired/turbo/blob/89be8e4c206ea877183b7ac4a89f898363a14f0f/src/http/fetch.js#L6

Error

Screenshot 2024-05-24 at 12 27 12 PM

Package.json

{
  "name": "app",
  "private": true,
  "dependencies": {
    "@hotwired/stimulus": "^3.2.2",
    "@hotwired/turbo-rails": "^8.0.4",
    "esbuild": "^0.21.3",
    "sass": "^1.77.2"
  },
  "scripts": {
    "build": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
    "build:css": "sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules"
  }
}

Gemfile

source "https://rubygems.org"

ruby "3.3.0"

gem "bcrypt", "~> 3.1.7"
gem "bootsnap", require: false
gem "cssbundling-rails"
gem "devise", "~> 4.9"
gem "image_processing", "~> 1.12"
gem "jbuilder"
gem "jsbundling-rails"
gem "pg", "~> 1.1"
gem "puma", ">= 5.0"
gem "rails", "~> 7.1.3"
gem "redis", ">= 4.0.1"
gem "simple_form", "~> 5.3"
gem "sprockets-rails"
gem "stimulus-rails"
gem "turbo-rails", '~> 1.0'

group :development, :test do
  gem "debug"
end

group :development do
  gem "htmlbeautifier"
  gem "web-console"
end

group :test do
  gem "capybara"
  gem "selenium-webdriver"
end

I'll be digging into this later, but wanted to throw the issue up.

This might be related to hotwired/turbo#1265. Similar to hotwired/turbo#1265 (comment), could you share more information about how the turbo and stimulus dependencies are being loaded by the browser?

Since hotwired/turbo#1265 has been closed, could this also be closed?

The function in set_operations.ts shouldn't be leaking into the global window namespace. Looking at hotwired/turbo#1265 this seems to be the case. Going to close this for now. Please feel to re-open if you see anything else unexpected.