-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Archive this repo? #656
Comments
Would this not still be useful because of the imports? |
@robclancy You don't have to import fetch in a modern browser. It's part of the standard library (Web APIs). |
I think this project would still have a large influence on fastboot apps 🤔 since fetch is a web api and it hasn't been added to V8 or Node. I don't know the specifics of this but I get the feeling that archiving this project would be a bit extreme |
IE 11 is still supported by Microsoft and it will be at least another nine months before we can reasonably start dropping support for it. This request is premature. |
To complement this answer: https://docs.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge
|
I don't think this is a good argument for keeping ember-fetch, because:
|
I am not sure if this package can simply be deprecated without migration guide. I tried to remove it from my app with ember-concurrency tasks and the moment I switch to native fetch, we no longer have runloop wrapping and tests simply fail, because component instances etc. in tests don't wait for async things to finish. Sure I can use https://github.com/emberjs/ember-test-waiters#waitforpromise-function for example to wrap things for test waiter to understand that there is async work still pending but it's not as simple as -- It might be easier to create wrapped -- This package could exist for transition period as wrapper provider for native fetch just for test waiter purposes 🤔 . |
Node 16 or.. 17? Now has fetch. Is it time to archive? |
Archiving this is not the actual work required. Somebody needs to ship the replacement that keeps everybody's test suites still working with the same behavior as before. Probably that code should still just live in this package. The only change apps should be told to do is to delete the actual
Done that way, it wouldn't even require a breaking change. You could do a minor. It would deprecate importing fetch from ember-fetch, with a message telling people to just delete the import statement. That makes it an easy upgrade. |
I believe that currently it would only properly integrate with the test waiters when using the import, not? That's at least how I read this code Given that the addon
can't we instead let users that don't need it anymore - as they use modern browsers + node 16 (in case of FastBoot) - just use the global DOM API, and add some magic to So for "modern" apps, they would just use "the platform", not have to install additional addons, but still have proper test integration. |
Yes, that sounds good to me. So to roll this out we need to
1. Do the feature in ember/test-helpers to make it hook into global fetch.
(This work must be fastboot-compatible too).
2. Do a feature in fastboot that provides a fetch global on node versions
that don’t have it. This can be in the actual “fastboot” package. It can
use the same polyfill that ember-fetch was using.
3. Archive ember-fetch with clear instructions on deleting the imports and
upgrading ember/test-helpers and fastboot.
4. Update the ember app blueprint to remove ember-fetch.
…On Thu, Jun 30, 2022 at 1:30 PM Simon Ihmig ***@***.***> wrote:
I believe that currently it would only properly integrate with the test
waiters when using the import, not? That's at least how I read this code
<https://github.com/ember-cli/ember-fetch/blob/master/assets/browser-fetch.js.t#L55-L65>
Given that the addon
- uses so much broccoli magic (just look at index.js
<https://github.com/ember-cli/ember-fetch/blob/master/index.js>)
- and other APIs that IMHO should eventually go away / be deprecated
(like explicit define() usage, or Ember.Test)
- in that shape is hardly migratable to v2 format (I assume?)
can't we instead let users that don't need it anymore - as they use modern
browsers + node 16 (in case of FastBoot) - just use the global DOM API, and
add some magic to @ember/test-helpers's settled()
<https://github.com/emberjs/ember-test-helpers/blob/master/addon-test-support/%40ember/test-helpers/settled.ts>
so that it is able to add test-waiter tracking of native fetch. It does
already a bunch of settledness checks (including support for jQuery.ajax
😁).
So for "modern" apps, they would just use "the platform", not have to
install additional addons, but still have proper test integration.
—
Reply to this email directly, view it on GitHub
<#656 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACN6MWNZMHXLJQN2SYWAVTVRXKVBANCNFSM5DUE7CLQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I have a question about the tests wrapping For testing, we use To get it to work in our tests, we had to wrap those WRAPPED_RESPONSE_FUNCTIONS.forEach((fn) => {
let nativeFn = this[`_nativeResponse${fn}`] = Response.prototype[fn];
Response.prototype[fn] = function(...args) {
return waitForPromise(nativeFn.call(this, ...args));
};
}); With both the native and polyfill support, I don't know the best way to fix this here + I don't know if there's any interest in fixing this in this repo in the first place. Any chance this can be picked up at some point? |
I just saw this discussion and I could not possibly disagree more strongly with the idea that we should patch global My own opinion here is that the right move is:
That latter point gets at why I think patching If, in your app, you want a wrapped import { waitForPromise } from '@ember/test-waiters';
export function fetch(...fetchArgs) {
return waitForPromise(window.fetch(...fetchArgs));
} What's more, that leaves every app in control of their own handling for this, so that if (as you note in your own example here) you need further customization for your own particular test setup, you can just write that. It also makes it really obvious for someone new to that app where and how this is implemented when they want to understand it. One of the great upsides to imports is they give you breadcrumbs to follow. (Insofar as it's useful to have that exist as a shared behavior, I think there's a reasonable argument that this and only this is what |
I'll add: I'm aware that this means you have to do one of two things when interacting with third-party libraries which themselves do a
Most well-behaved data fetching libraries (e.g. Apollo) already allow you to do the second, so you could just pass them a wrapped Critically, in both cases, you're not invisibly changing the behavior of third-party libraries in ways they cannot anticipate. Addendum: the fact that other frameworks do shenanigans like this is not itself a very good argument to me. Imports are great! |
We have a robust spec for The disagreement here comes down to a philosophical question: I think our test suite environment is an ECMAScript host environment that should be free to implement any of the environment-provided features in any spec-compliant way that it wants. In the testing context, we have enough control to decide what constitutes "environment creation" vs "inside the tests". We can provide full-fidelity to the inside of the tests.
There are at least two bright lines. The first is what I already said, which is that monitoring all promises in a way that is both complete and spec-compliant is not nearly as easy as monitoring fetch. The spec for promises allows significantly more extensibility. Not all operations go through window.Promise or window.Promise.prototype.then. The second is that, from a testing ergonomics perspective, monitoring every promise is not what you really want anyway. By analogy with tracked properties, where it's nicer to just track the roots of state and not try to track every intermediate result, the "roots of asynchrony" are operations like |
Also keep in mind we're talking only about test environments here. Where one of the most prevalent testing strategies in the community is already replacing fetch anyway! |
Now that Ember 4.0.0 is out and IE 11 is no longer supported, maybe it's easiest to just archive this repo, with a note in the readme explaining that it has served it's purpose.
Possibly coupled with a deprecation notice when this addon is used in an Ember >= 4.0.0 project
People can still use it, but we shouldn't spend more time on it.
https://caniuse.com/fetch
The text was updated successfully, but these errors were encountered: