Comments (5)
Ugh good catch.
from partykit.
Should be fairly easy to reproduce. I get the RAM bump after 3-5 edits.
from partykit.
Okay, doing some profiling of this and I can see that the useEffect()
that creates esbuild.context()
is called numerous times upon incremental change:
# Initial run: partykit dev
useEffect: called!
runBuild: called!
runBuild: added partykit plugin!
# Incremental change:
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
useEffect: called!
runBuild: called!
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
runBuild: added partykit plugin!
Build succeeded, starting server...
The parent useDev()
hook is also called multiple times upon incremental changes.
@threepointone, can you tell me more about why esbuild is used in a React's hook? That's quite unusual :D
I also suspect that keeping ctx
as a variable scoped to useEffect is a bad idea. useEffect can be called multiple times without cleaning up (whenever its dependency change). But we do nothing right now to dispose of ctx
when that happens.
from partykit.
I've trimmed down the initiator of useEffect
to be the assetsMap
variable. It contains all the assets emitted (by the build?) so, naturally, when I update a module, it may produce new assets or update exiting ones.
Here's an example of the assetsMap
diff that triggered useEffect
(i.e. runBuild
):
{
prevSource: {
current: {
devServer: 'http://127.0.0.1:49603',
browserTTL: undefined,
edgeTTL: undefined,
singlePageApp: undefined,
assets: [Object]
}
},
source: {
devServer: 'http://127.0.0.1:49603',
browserTTL: undefined,
edgeTTL: undefined,
singlePageApp: undefined,
assets: {
'arena.png': 'arena.png',
'background.png': 'background.png',
'favicon.ico': 'favicon.ico',
'manifest.json': 'manifest.json',
'mockServiceWorker.js': 'mockServiceWorker.js',
'sign.png': 'sign.png',
'fonts/morris-roman.black.ttf': 'fonts/morris-roman.black.ttf',
'dist/index.js': 'dist/index.js',
'dist/index.js.map': 'dist/index.js.map',
+ 'build/__remix_entry_dev-KOSYFGLN.js': 'build/__remix_entry_dev-KOSYFGLN.js',
+ 'build/__remix_entry_dev-KOSYFGLN.js.map': 'build/__remix_entry_dev-KOSYFGLN.js.map',
'build/css-bundle-URXWV324.css': 'build/css-bundle-URXWV324.css',
'build/css-bundle-URXWV324.css.map': 'build/css-bundle-URXWV324.css.map',
'build/entry.client-VNZNSQKD.js': 'build/entry.client-VNZNSQKD.js',
'build/entry.client-VNZNSQKD.js.map': 'build/entry.client-VNZNSQKD.js.map',
'build/manifest-5116B4E4.js': 'build/manifest-5116B4E4.js',
'build/root-I4ZBLVPU.js': 'build/root-I4ZBLVPU.js',
'build/root-I4ZBLVPU.js.map': 'build/root-I4ZBLVPU.js.map',
+ 'build/root-RJOJ2B3P.css': 'build/root-RJOJ2B3P.css',
+ 'build/root-RJOJ2B3P.css.map': 'build/root-RJOJ2B3P.css.map',
+ 'build/routes/_index-DXQU5XVU.js': 'build/routes/_index-DXQU5XVU.js',
'build/routes/_index-DXQU5XVU.js.map': 'build/routes/_index-DXQU5XVU.js.map',
'build/routes/game.admin-3Y3BYEWW.js': 'build/routes/game.admin-3Y3BYEWW.js',
'build/routes/game.admin-3Y3BYEWW.js.map': 'build/routes/game.admin-3Y3BYEWW.js.map',
'build/_shared/browser-Z2C4YXXQ.js': 'build/_shared/browser-Z2C4YXXQ.js',
'build/_shared/browser-Z2C4YXXQ.js.map': 'build/_shared/browser-Z2C4YXXQ.js.map',
+ 'build/_shared/chunk-ACACETXL.js': 'build/_shared/chunk-ACACETXL.js',
+ 'build/_shared/chunk-ACACETXL.js.map': 'build/_shared/chunk-ACACETXL.js.map',
+ 'build/_shared/chunk-H36SQQE5.js': 'build/_shared/chunk-H36SQQE5.js',
+ 'build/_shared/chunk-H36SQQE5.js.map': 'build/_shared/chunk-H36SQQE5.js.map',
+ 'build/_shared/chunk-IHZXMV55.js': 'build/_shared/chunk-IHZXMV55.js',
+ 'build/_shared/chunk-IHZXMV55.js.map': 'build/_shared/chunk-IHZXMV55.js.map',
+ 'build/_shared/chunk-JKUASME7.js': 'build/_shared/chunk-JKUASME7.js',
+ 'build/_shared/chunk-JKUASME7.js.map': 'build/_shared/chunk-JKUASME7.js.map',
'build/_shared/chunk-JXHNNPNR.js': 'build/_shared/chunk-JXHNNPNR.js',
'build/_shared/chunk-JXHNNPNR.js.map': 'build/_shared/chunk-JXHNNPNR.js.map',
+ 'build/_shared/chunk-LCVWOUJY.js': 'build/_shared/chunk-LCVWOUJY.js',
+ 'build/_shared/chunk-LCVWOUJY.js.map': 'build/_shared/chunk-LCVWOUJY.js.map',
+ 'build/_shared/chunk-N4FG5RPV.js': 'build/_shared/chunk-N4FG5RPV.js',
+ 'build/_shared/chunk-N4FG5RPV.js.map': 'build/_shared/chunk-N4FG5RPV.js.map',
+ 'build/_shared/chunk-RODUX5XG.js': 'build/_shared/chunk-RODUX5XG.js',
+ 'build/_shared/chunk-RODUX5XG.js.map': 'build/_shared/chunk-RODUX5XG.js.map',
+ 'build/_shared/chunk-TVZC3ZTX.js': 'build/_shared/chunk-TVZC3ZTX.js',
+ 'build/_shared/chunk-TVZC3ZTX.js.map': 'build/_shared/chunk-TVZC3ZTX.js.map',
'build/_shared/client-5VJPMT66.js': 'build/_shared/client-5VJPMT66.js',
'build/_shared/client-5VJPMT66.js.map': 'build/_shared/client-5VJPMT66.js.map',
'build/_shared/esm-ST23SWPS.js': 'build/_shared/esm-ST23SWPS.js',
'build/_shared/esm-ST23SWPS.js.map': 'build/_shared/esm-ST23SWPS.js.map',
'build/_shared/jsx-dev-runtime-O7QZHBCI.js': 'build/_shared/jsx-dev-runtime-O7QZHBCI.js',
'build/_shared/jsx-dev-runtime-O7QZHBCI.js.map': 'build/_shared/jsx-dev-runtime-O7QZHBCI.js.map',
'build/_shared/jsx-runtime-4JVBCWRJ.js': 'build/_shared/jsx-runtime-4JVBCWRJ.js',
'build/_shared/jsx-runtime-4JVBCWRJ.js.map': 'build/_shared/jsx-runtime-4JVBCWRJ.js.map',
'build/_shared/react-44WC4HVE.js': 'build/_shared/react-44WC4HVE.js',
'build/_shared/react-44WC4HVE.js.map': 'build/_shared/react-44WC4HVE.js.map',
'build/_shared/react-dom-HTVZIA6L.js': 'build/_shared/react-dom-HTVZIA6L.js',
+ 'build/_shared/react-dom-HTVZIA6L.js.map': 'build/_shared/react-dom-HTVZIA6L.js.map',
+ 'build/_shared/remix_hmr-ULZE7MV6.js': 'build/_shared/remix_hmr-ULZE7MV6.js',
+ 'build/_shared/remix_hmr-ULZE7MV6.js.map': 'build/_shared/remix_hmr-ULZE7MV6.js.map',
+ 'build/_shared/runtime-GJVYN4KP.js': 'build/_shared/runtime-GJVYN4KP.js',
+ 'build/_shared/runtime-GJVYN4KP.js.map': 'build/_shared/runtime-GJVYN4KP.js.map'
}
}
}
What's odd, is that all I did in this scenario is hit CMD+S without making any actual changes to the code. The fact that it produces new modules and sourcemaps is... odd.
from partykit.
I'm convinced the fix would be not to create a scoped ctx
but instead keep a hook-level useRef
for the context where any current build is stored. When a new build starts (useEffect triggers), the last reference to the build must be disposed of before esbuild.context()
is ever called. I'm trying this now to little success but I'm editing the 100k LOC node module so I'm a bit slow.
from partykit.
Related Issues (20)
- Feature request: Add rawProtocol param for y-partykit HOT 6
- Bun not working HOT 3
- bug: deploy - windows compatibility issue for wasm files HOT 2
- use npm: specifiers in partykit.json for main/parties
- Fine-grained Permissions possible? HOT 1
- Y.js V2 Update Format HOT 4
- PartySocket.fetch -- docs and host param
- This expression is not constructable HOT 1
- Make Party.Room constructor public HOT 2
- PartyKit Quickstart fails to open on macOS HOT 5
- Cannot use @jupyterlab/services: setImmediate is not defined
- Updating `Y.Doc` server-side HOT 5
- Very high number of Internal errors
- Load environment variables from alternate .env files
- CLI dev --tunnel flag to auto create Cloudflare Tunnel HOT 1
- [idea] Use Content Defined Chunking For Storing Yjs
- (might be a y-prosemirror issue) Unable to update a yjs doc via YPartykitProvider from outside of prosemirror
- Browser Rendering Binding HOT 1
- Error: invalid or missing json property for binding PARTYKIT_AI HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from partykit.