TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Counterintuitive web worker behavior

51 pointsby 0xedbover 2 years ago

10 comments

eyelidlessnessover 2 years ago
Maybe it’s because my brain is tired, but I had to reread the article several times to understand that the takeaway isn’t about something counterintuitive about the behavior <i>of web workers</i>, but about counterintuitive behavior discovered in their own app when attempting to apply web workers to solve a then-misunderstood problem.<p>Definitely not a better title, but a clearer synopsis: web workers [were] not the [appropriate solution to the problem we set out to solve, in fact their constraints helped us discover an extant problem and address it. Nothing peculiar or otherwise about web workers was implicated].<p>It’s possible this realization has broader value: digging in to better understand a problem and finding the appropriate solution is different than you presupposed are important skills! But I do think the title and summary do it a disservice. And I’m wary of how that might mistakenly influence people to reflexively dismiss web workers for appropriate use cases.
azangruover 2 years ago
The blog post is littered with React code (plus Apollo). Which part of the problem was specific to the workers - and how can this lesson be generalized to any FE framework, or no framework at all?
评论 #33240568 未加载
评论 #33240824 未加载
sangeeth96over 2 years ago
I wonder if the team ever tried the React DevTools Profiler or something like why-did-you-render[0] to debug and find the root cause, before going the counter&#x2F;manual method?<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;welldone-software&#x2F;why-did-you-render" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;welldone-software&#x2F;why-did-you-render</a>
duderificover 2 years ago
&gt; simply moved our use of useSubscription() into a component that simply returned null. That way, the extraneous renders that were being triggered by useSubscription() would be extremely cheap because the component had virtually no re-render cost.<p>It seems like maybe the API provider (Apollo) should provide a way to avoid the extraneous renders. Maybe this is unavoidable due to the React hooks architecture.
abrahamover 2 years ago
The big surprise to me is neither PR included any tests to prevent regressions.
NaughtyShibaover 2 years ago
Nice read, thanks for that!<p>However, I would say it doesn’t emphasise issue, from React’s perspective, enough.<p>Languages like C++ or Rust, where pointer&#x2F;reference definitions are required, has an advantage that you won’t miss the fact that something has pointer.<p>Worthy mention - `additionalProperties` property of `react-hooks&#x2F;exhaustive-deps` ESLint rule, allows to define hooks which requires referential stability for dependencies. Personally, I’ve yet to use it.
评论 #33241605 未加载
ilakshover 2 years ago
Interesting article, bad title.<p>Not that I don&#x27;t appreciate the effort, but the more articles I see like this, it starts to make me wonder. In the future will I have to write a full report with infographics every time I debug or optimize something?<p>Imagine how much more productive engineers could be these days if they didn&#x27;t have to do a presentation or book tour every time they solved a problem.
eyelidlessnessover 2 years ago
I see the title has been edited. The title at the time I’m noticing it, “counterintuitive web worker behavior” is even less representative of the article’s content than the original.
khueyover 2 years ago
The title here is clickbait and what the article is really about is that fully understanding your problem before you start making changes to fix it leads to simpler and better fixes.
candiddevmikeover 2 years ago
Only a junior developer deals in absolutes. Web workers are sometimes the answer, and if you can work within their constraints, will free up your main thread and speed up your SPA or rendering.
评论 #33240140 未加载
评论 #33243013 未加载
评论 #33240623 未加载