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

fix(http/file_server): dealing with dir listing view that contain system files #3371

Merged
merged 6 commits into from
May 10, 2023

Conversation

ayame113
Copy link
Contributor

@ayame113 ayame113 commented May 7, 2023

close #3141

When I launch a file server in the Windows root directory and access http://localhost:4507/, I get a 500 Internal Server Error.
It seems that the following error occurs internally. These are Windows system files that reject Deno.stat calls.

The process cannot access the file because it is being used by another process. (os error 32): stat 'C:\/DumpStack.log.tmp'
The process cannot access the file because it is being used by another process. (os error 32): stat 'C:\/hiberfil.sys'
The process cannot access the file because it is being used by another process. (os error 32): stat 'C:\/pagefile.sys'
Access is Denied. (os error 5): stat 'C:\/PerfLogs'
Access is Denied. (os error 5): stat 'C:\/Recovery'
The process cannot access the file because it is being used by another process. (os error 32): stat 'C:\/swapfile.sys'
Access is Denied. (os error 5): stat 'C:\/System Volume Information'

This PR adds a try-catch around the Deno.stat call so that directory listing views are generated even for directories containing system files.
After this PR, the display of the root directory page looks like this:
image

@ayame113 ayame113 requested a review from kt3k as a code owner May 7, 2023 15:54
Comment on lines 60 to 62
stdout: "piped",
stderr: "null",
stderr: "inherit",
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this line will make debugging easier as error messages will be displayed instead of discarded. It was a minor change so I've included it in this PR.

}

return createCommonResponse(Status.NotFound);
}

function logError(error: unknown) {
console.error(
red(error instanceof Error ? error.message : "[non-error thrown]"),
Copy link
Member

Choose a reason for hiding this comment

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

Not directly related to this change, but "[non-error thrown]" message doesn't look useful. How about just printing error itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. It has changed! (d8137cb)

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k kt3k merged commit f7357c0 into denoland:main May 10, 2023
7 checks passed
@ayame113 ayame113 deleted the server-os-error branch May 10, 2023 06:25
mxdvl pushed a commit to mxdvl/deno_std that referenced this pull request May 16, 2023
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.

file_server different path open results unexpectedly so large
2 participants