Skip to content

Commit

Permalink
🔊 Add even more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Dec 28, 2024
1 parent 8db597e commit 12843cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
24 changes: 7 additions & 17 deletions packages/core/src/service/FileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export class ArchiveUriSupporter implements UriProtocolSupporter {
*/
private constructor(
private readonly externals: Externals,
private readonly logger: Logger,
private readonly entries: Map<string, Map<string, DecompressedFile>>,
) {}

Expand Down Expand Up @@ -290,6 +291,9 @@ export class ArchiveUriSupporter implements UriProtocolSupporter {

*listFiles() {
for (const [archiveName, files] of this.entries.entries()) {
this.logger.info(
`[ArchiveUriSupporter#listFiles] Listing ${files.size} files from ${archiveName}`,
)
for (const file of files.values()) {
yield ArchiveUriSupporter.getUri(archiveName, file.path)
}
Expand Down Expand Up @@ -340,36 +344,22 @@ export class ArchiveUriSupporter implements UriProtocolSupporter {
if (entries.has(archiveName)) {
throw new Error(`A different URI with ${archiveName} already exists`)
}
/// Debug message for #1609
logger.info(
`[ArchiveUriSupporter#create] Extracting archive ${archiveName} from ${uri}`,
)
const files = await externals.archive.decompressBall(
await externals.fs.readFile(uri),
{ stripLevel: typeof info?.startDepth === 'number' ? info.startDepth : 0 },
)
const newEntries = new Map(files.map((f) => [f.path.replace(/\\/g, '/'), f]))
/// Debug message for #1609
logger.info(
`[ArchiveUriSupporter#create] Extracted ${files.length} files, adding ${newEntries.size} entries`,
`[ArchiveUriSupporter#create] Extracted ${files.length} files from ${archiveName}`,
)
for (const [path, entry] of [...newEntries.entries()].slice(0, 20)) {
logger.info(`[ArchiveUriSupporter#create] ${path} (${entry.data.length} bytes)`)
}
entries.set(archiveName, newEntries)
entries.set(archiveName, new Map(files.map((f) => [f.path.replace(/\\/g, '/'), f])))
}
} catch (e) {
logger.error(`[ArchiveUriSupporter#create] Bad dependency ${uri}`, e)
}
}

/// Debug message for #1609
logger.info(
`[ArchiveUriSupporter#create] Finalizing with ${entries.size} archives: ${[
...entries.keys(),
]}`,
)
return new ArchiveUriSupporter(externals, entries)
return new ArchiveUriSupporter(externals, logger, entries)
}
}

Expand Down
19 changes: 19 additions & 0 deletions packages/core/src/service/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,16 @@ export class Project implements ExternalEventEmitter {
*/
getTrackedFiles(): string[] {
const extensions: string[] = this.meta.getSupportedFileExtensions()
this.logger.info(`[Project#getTrackedFiles] Supported file extensions: ${extensions}`)
const supportedFiles = [...this.#dependencyFiles ?? [], ...this.#watchedFiles]
.filter((file) => extensions.includes(fileUtil.extname(file) ?? ''))
this.logger.info(
`[Project#getTrackedFiles] Listed ${supportedFiles.length} supported files`,
)
const filteredFiles = this.ignore.filter(supportedFiles)
this.logger.info(
`[Project#getTrackedFiles] After ignoring, keeping ${filteredFiles.length} tracked files`,
)
return filteredFiles
}

Expand Down Expand Up @@ -585,6 +592,18 @@ export class Project implements ExternalEventEmitter {
const files = [...addedFiles, ...changedFiles].sort(this.meta.uriSorter)
__profiler.task('Sort URIs')

const fileCountByExtension = new Map<string, number>()
for (const file of files) {
const ext = fileUtil.extname(file)?.replace(/^\./, '')
if (ext) {
fileCountByExtension.set(ext, (fileCountByExtension.get(ext) ?? 0) + 1)
}
}
this.logger.info(`[Project#ready] == Files to bind ==`)
for (const [ext, count] of fileCountByExtension.entries()) {
this.logger.info(`[Project#ready] File extension ${ext}: ${count}`)
}

const __bindProfiler = this.profilers.get('project#ready#bind', 'top-n', 50)
for (const uri of files) {
await this.ensureBindingStarted(uri)
Expand Down

0 comments on commit 12843cf

Please sign in to comment.