Skip to content
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

Merged
merged 14 commits into from
Oct 14, 2024
Merged

Nadav/handle route exports #1225

merged 14 commits into from
Oct 14, 2024

Conversation

nadav-ab
Copy link
Contributor

No description provided.

Copy link
Contributor

@idoros idoros left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor Author

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',
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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 )

Copy link
Contributor Author

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

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@nadav-ab nadav-ab merged commit 36de4ef into master Oct 14, 2024
6 checks passed
@nadav-ab nadav-ab deleted the nadav/handle-route-exports branch October 14, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants