-
Notifications
You must be signed in to change notification settings - Fork 8
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
Nadav/handle route exports #1225
Conversation
…/handle-route-exports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't new to the code, but this PR introduces many additional listeners to the module system. I'm concerned that these listeners are not being properly disposed of, which could lead to accumulating observers on the module system and potential memory leaks.
import { Outlet, useLoaderData } from '@remix-run/react'; | ||
const loaderPromise = new Promise((resolve) => { | ||
const globalListener = () => { | ||
debugger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (newEmail && newFullName) { | ||
userNames.set(nickname, { email: newEmail, fullName: newFullName }); | ||
return json({ | ||
message: existing ? 'User updated' : 'User created', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test for "User updated" or "User does not exist"? maybe simplify the fixture?
|
||
const importModuleAndUpdate: DynamicImport = (filePath, cb) => { | ||
const { moduleResults, dispose } = requireModule(filePath, (newResults) => { | ||
setHandle((newResults.results as { handle?: unknown }).handle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ok as the module system returns {}
on error, but maybe the DynamicImport
should be generic and the remix integration could expect it's own module interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe but not in this PR
setHandle((newResults.results as { handle?: unknown }).handle); | ||
const linksFunction = (newResults.results as { links?: LinksFunction }).links; | ||
if(linksFunction){ | ||
setLinks(linksFunction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the condition here prevent links from being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or added if it was not there to begin with, i need to somehow revoke the memo of the router when an export is added or removed ( relevant for all conditional route exports )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, the manifest changes when the exportnames change, revoking the memo, adding a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a test and fix
return isSerializedResponse(res) ? deserializeResponse(res) : res; | ||
const lastResults: { current: IResults<unknown> } = { current: { status: 'loading', results: null } }; | ||
const { moduleResults } = importModuleAndUpdate(filePath, (updated) => { | ||
lastResults.current = updated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What handles an error in loader after the loader updates into an error state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont understand the question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we start with a valid page that has a loader and then it becomes invalid, then the lastResults
reference the stale previous value. Maybe it doesn't matter.
…odux-core into nadav/handle-route-exports
No description provided.