Skip to content

Bugs in code don't error in development #5174

Closed as not planned
Closed as not planned

Description

@harbar20

What version of Remix are you using?

1.11

Steps to Reproduce

This is how I discovered this issue:

  1. run npx create-remix@latest. "Just the Basics," "Remix App Server," "Typescript, and "yes" to run npm install.
  2. Open the project
  3. Run npm run dev and take a look at what it generated. It should work just fine.
  4. Ctrl+C to stop it. Run npm install @azure/msal-node in the console. I used version 1.14.6.
  5. in app/models, create a file called microsoftClientApp.ts and paste the following:
import { PublicClientApplication } from "@azure/msal-node";

export let clientApp = new PublicClientApplication({
    auth: {
        clientId: process.env.CLIENT_ID || "",
        authority: ""
    }
})
  1. in app/routes/index.ts, create a loader as follows:
export let loader: LoaderFunction = async ({ request }) => {
	const authRequest: AuthorizationCodeRequest = {
		scopes: [
			"User.Read",
			"Calendars.Read",
			"Calendars.Read.Shared",
			"Calendars.ReadWrite",
			"Calendars.ReadWrite.Shared",
		],
		redirectUri: process.env.REDIRECT_URI || "",
		code: "",
  };
  const microsoftAuthURL = await clientApp.getAuthCodeUrl(authRequest);
  return json(authRequest);
  // return json({ url: microsoftAuthURL });
};

and paste the following at the top of the Index function:

  const data = useLoaderData<typeof loader>();
  1. Change something about the existing JSX. It doesn't matter what you change (I just added some <p> tags with random text at the top), just add something that wasn't there before.
  2. run npm run dev in the console. It should run just fine, and for some reason, you'll see that it generates what it generated before. That is, it won't have the changes you made to it.
  3. Ctrl+C to stop it. Now run npm run build. You should see some error about polyfills and HTTP. This error is not the point. The point is, running npm run dev should have shown you this error and not have just generated the last page it had generated.

If you comment out the loader function and all that, you'll see that all of a sudden, running npm run dev generates the changes you made in Index.

Expected Behavior

What should happen is everything that happened above, except instead of just loading the previously-generated page, it should show you the error that came in build and just not generate the page at all. Bugs should be shown clearly to the developer while running the app in development mode.

Actual Behavior

It didn't show me the error that came up while building, and instead just loaded the previously-generated page (the page that existed before you added the changes to Index).

Activity

  1. changed the title [-]Bugs in code don't erro in development[/-] [+]Bugs in code don't error in development[/+] on Jan 21, 2023
  2. machour commented on Jan 21, 2023

    @machour
    Contributor

    There's already a proposal to have this feature: #4196

    Please upvote it so it gets picked in the roadmap weekly meeting 🙏

  3. kiliman commented on Jan 24, 2023

    @kiliman
    Contributor

    I have a sample app with a patch that adds support for this.

    https://github.com/kiliman/remix-build-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions