-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
request.cache throws "TypeError: This property is not implemented." #10286
Comments
This is working as intended. We do not implement HTTP cache yet, so accessing this field throws. This is consistent with other server side |
@lucacasonato I understand that certain aspects are not implemented, but the behavior of throwing on access is not consistent with other server side implementations. To use your cited example:
import {Request} from 'node-fetch';
const request = new Request('https://api.github.com/repos/denoland/deno');
console.log(request.cache); //=> undefined |
Try yourself at https://cloudflareworkers.com/. |
Do you have a usecase for why you don't want |
It is exactly for this reason that I expect accessing these props to not throw. It would never throw in a browser and deviating from that requires a divergence in application logic for Deno vs web. In web, we just compare the value of the props, but in Deno |
Again, do you have a use case? |
Yes. I want to write portable logic that has as little Deno special runtime code as possible. Isn't that one of the major goals of the project?
↳ https://deno.land/manual#goals Emphasis on "without change". Throwing when accessing these properties is not browser-compatible. |
Ok I have thought about this some more, and I guess this does make sense. We should remove all of the unimplemented methods. |
@lucacasonato What made you backtrack? |
@jsejcksn That's an incorrect understanding of the compatibility rule. Making it throw marks it as an invalid Deno program so by the rule it doesn't have to work in browsers. Returning a non-spec value can technically violate the rule. BUT returning To explain for example why we make the Half of that would seem to apply here, we don't want people to have to null-check |
That this is how unimplemented functionally in browsers behave. It just isn't there. |
Edit: It appears this is for all requests:
In Deno v
1.9.1
: for eachDeno.RequestEvent
yielded byDeno.serveHttp
, accessing the value ofrequestEvent.request.cache
throws a TypeError.Here is the source:
deno/op_crates/fetch/23_request.js
Lines 341 to 344 in a1ac17f
This did not occur in
1.9.0
(the value wasundefined
). See the reproduction case below:Reproduce:
example.ts
:stderr
:Version
The text was updated successfully, but these errors were encountered: