-
Notifications
You must be signed in to change notification settings - Fork 30k
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
stream: fix web streams have no Symbol.toStringTag #45117
stream: fix web streams have no Symbol.toStringTag #45117
Conversation
e1be9bb
to
c1cb095
Compare
Looks like there are some relevant build failures that are pretty easy to address :] |
I don't understand how switching to a getter fixes the issue. |
Actually, we missed the getter implementation before. It should be a getter, to return some results. |
I will check it out and fix next day. Its seems like missing of setters. But, we don't need setters anymore. I will fix them. |
Here's what I understand: when using a getter, it sets a
I disagree, I think we should not be using getters at all, none of the other implementations (I tried Firefox, Safari, Chromium, and Deno) use a getter for > console.log(Object.getOwnPropertyDescriptor(TransformStream.prototype, Symbol.toStringTag))
Object { value: "TransformStream", writable: false, enumerable: false, configurable: true } IMHO a better fix would be (I'm using diff --git a/lib/internal/webstreams/transformstream.js b/lib/internal/webstreams/transformstream.js
index b7366fb1ba..114d4d4e16 100644
--- a/lib/internal/webstreams/transformstream.js
+++ b/lib/internal/webstreams/transformstream.js
@@ -102,8 +102,6 @@ const assert = require('internal/assert');
class TransformStream {
[kType] = 'TransformStream';
- get [SymbolToStringTag]() { return this[kType]; }
-
/**
* @param {Transformer} [transformer]
* @param {QueuingStrategy} [writableStrategy]
@@ -236,6 +234,11 @@ class TransformStream {
ObjectDefineProperties(TransformStream.prototype, {
readable: kEnumerableProperty,
writable: kEnumerableProperty,
+ [SymbolToStringTag]: {
+ __proto__: null,
+ value: 'TransformStream',
+ configurable: true,
+ }
}); |
I would like to keep the getter here, while comparing the other implementation areas of In short, there are many places we sets the property because while reading the |
c1cb095
to
8aad2ba
Compare
This doesn't have anything to do with using a getter or using a value, right?
Yeah, that's why I was saying if we are no longer using getters, it fixes the issue AND it aligns with the other implementations. I feel quite strongly that getters are not the way to go here. |
We are using |
I'm not asking for any setters, I'm asking to get rid of getters. If you look at the diff in #45117 (comment), hopefully you can see what I mean. |
What's the reason for your suggestion of not using getters? I am not intending to add some In this PR, I want to minimise the changes. |
Aligning with the other implementations should be enough of a reason. But also, by using a getter the
If you allow me to return you the question: what's the reason for your suggestion of minimising the changes? IMO producing the correct fix is more important than having a small diff, and arguably my suggestion wouldn't increase the magnitude of the diff.
I've opened #45136 as an alternative to this PR. |
It seems common implementations for built-in properties whose keys are # console.log(Object.getOwnPropertyDescriptor(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag)
# data property
{
value: 'ByteLengthQueuingStrategy',
writable: false,
enumerable: false,
configurable: true
}
# accessor property
{
get: [Function: get [Symbol.toStringTag]],
set: undefined,
enumerable: false,
configurable: true
} |
I am not trying to define I am fixing the undefined issue kType. For that, I don't like to make it more complex by the above suggestions. I want to proceed with the getter approach, and its looks more elegant to me. Thanks your suggestion. |
Also, I don't think its fair to discard someone’s pull request with an alternate PR. I stand with my changes because there is no difference between define property and getter. I dont want to override the implementation of toStringTag, instead I fixed the undefined kType, which is being used as a toStringTag. Also, i want to keep my changes very minimal. Code of conduct doc may need revisits. |
I'm sorry to hear that, I didn't want to discard your PR, I read "Feel free to make the changes on top of it" as an invitation to propose my changes separately. But to be fair, since you are not willing to take my suggestion, I don't think I had much choice but to open my own PR. What would you suggest me to do?
That is simply not true, of course there are observable differences between a getter and a non-writable property.
That's unfortunate, as IMO the
We might need to discuss this is a separate issue/PR to keep this one on topic, but if we can improve the CoC I'm all for it. |
You can make your suggestion later as different PR or commit on this PR. But, I can not accept your changes because there are no difference in them.
What's your achievement here? Are you saving execution time? By using the defineProperty, you are not fixing the root cause of the issue. The root cause is Also, there is no difference between the properties defined using getter, and defineProperty. However, if there are some difference, how it will impact the code quality? Many people over the world is contributing to this repository. Everyone will follow their own style of coding. For instance, someone will use ternary operator, someone will use if etc. There is nothing good or bad. If it is breaking the code quality, then we should not promote those changes, Here, its not violating the code quality. Its just a thought others applying here because they are not seeing the actual fix.
No-one is making changes to
You can disagree. I ma not checking other browsers to see the implementation. Can you provide the code or screenshot of that implementation? For your info, a getter is being converted to something we are adding with a define prop later. That may be the reason you are seeing it. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#defining_a_getter_on_existing_objects_using_defineproperty
Yes. People are using their privileges to discard others is not good practice. Please don't think others chooses are not right. Also, I don't want to discuss further as you are not understanding the getter and define props doing the similar results. I don't like to repeat the same conversations again. Thank you. |
dbf2c9a
to
6f86553
Compare
I think Antoine's point was that spec-wise this fits with a non-writable property and not a getter. There are several observable difference for example: class Foo {
get a() { return 5 }
}
Object.defineProperty(Foo.prototype, "b", {
value: 6,
configurable: true
});
const f = new Foo();
Object.getOwnPropertyDescriptor(f.__proto__, 'a');
// {set: undefined, enumerable: false, configurable: true, get: ƒ}
Object.getOwnPropertyDescriptor(f.__proto__, 'b');
// {value: 6, writable: false, enumerable: false, configurable: true} |
The initial suggestion was not acceptable. But, once its suggested with the wpt, I made the changes accordingly. |
eda0c87
to
1b8e812
Compare
4f28416
to
a1f6faf
Compare
stream: fix web streams have no Symbol.toStringTag stream: add unit tests
a1f6faf
to
1e4a210
Compare
Landed in e9ba08e |
Thanks @MrJithil ! |
stream: fix web streams have no Symbol.toStringTag stream: add unit tests PR-URL: #45117 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
stream: fix web streams have no Symbol.toStringTag stream: add unit tests PR-URL: #45117 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
stream: fix web streams have no Symbol.toStringTag stream: add unit tests PR-URL: #45117 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
stream: fix web streams have no Symbol.toStringTag stream: add unit tests PR-URL: #45117 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
stream: fix web streams have no Symbol.toStringTag stream: add unit tests PR-URL: #45117 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
fix web streams have no Symbol.toStringTag
Issue: #45114