Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Record tsc compiled code #170

Merged
merged 3 commits into from
Feb 1, 2023
Merged

Record tsc compiled code #170

merged 3 commits into from
Feb 1, 2023

Conversation

dustinbyrne
Copy link
Contributor

@dustinbyrne dustinbyrne commented Jan 6, 2023

This fixes an issue found while trying to record @appland/scanner and adds some additional test cases.

Resolves #173

@lachrist
Copy link
Contributor

Hi @dustinbyrne thanks for digging into this. The trace post-processing is rather complex and I remember that the pipeline of modules relies on assertion made earlier. So I don't think you can simply silence assertions. However I agree that producing something is better than panicking. I think the best way to proceed is to try the complex event re-ordering. If it fails (via assertions) we can try a simpler post-processing where we simply make sure the produced appmap is valid but we do not make any guarantee on the order of events.

@dustinbyrne
Copy link
Contributor Author

There are two items blocking this:

First, all AppMaps recorded from Jest tests are empty. This may be related to #172 where a transform is being applied. After all, this is using ts-jest. It may also be a configuration issue, but process recordings are functional. TBD.

Lastly, Jest command line arguments are not being transformed safely, and I've yet to come up with a strategy which doesn't involve mirroring Jests command line logic. Here are some examples where it breaks down.

$ npx jest authn

Would result in the following transformed command:

$ npx jest --runInBand --setupFilesAfterEnv /module/path.js authn

This is incorrect because authn will be read in as a setup file instead of a test path pattern. To retain the same behavior, the command would be one of the following:

$ npx jest --runInBand --setupFilesAfterEnv /module/path.js -- authn
$ npx jest --runInBand --setupFilesAfterEnv /module/path.js --testPathPattern authn

This is complicated by the fact that the user may add other options to the command line:

$ npx jest --detectOpenHandles authn

Would need to resolve to one of the following:

$ npx jest --runInBand --setupFilesAfterEnv /module/path.js --detectOpenHandles -- authn
$ npx jest --runInBand --setupFilesAfterEnv /module/path.js --detectOpenHandles --testPathPattern authn

This is again complicated by the fact that we don't know if authn is a test path pattern or an argument of detectOpenHandles. Any tokens remaining after parsing options are treated as test path patterns. Ideally, we would not want to re-implement this logic as it's likely to change (and probably already has across versions).

@lachrist
Copy link
Contributor

Ah I did not expect --setupFilesAfterEnv to eats all the non-dashed argument after it. The fix with the transformer will require to parse both the configuration file and the arguments. I will make sure I take this into account.

@dustinbyrne dustinbyrne force-pushed the fix/record-scanner branch 2 times, most recently from f25ed49 to 5a1b22c Compare January 18, 2023 21:34
@dustinbyrne
Copy link
Contributor Author

The transformer fix is in the works and I've opened a separate issue for the Jest command line arguments (#179).

I don't think it's worth waiting for the outstanding items before shipping these.

@dustinbyrne dustinbyrne marked this pull request as ready for review January 18, 2023 22:19
@dustinbyrne dustinbyrne requested a review from lachrist January 18, 2023 22:19
lachrist
lachrist previously approved these changes Jan 20, 2023
Copy link
Contributor

@lachrist lachrist left a comment

Choose a reason for hiding this comment

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

Thanks for the work. Some information on the failures you had related the two last commits would help. Cheers!

components/agent/default/source-map.mjs Outdated Show resolved Hide resolved
components/agent/default/source-map.mjs Outdated Show resolved Hide resolved
components/trace/appmap/classmap/entity.mjs Outdated Show resolved Hide resolved
components/hook-group/node/index.mjs Show resolved Hide resolved
components/hook-group/node/index.mjs Show resolved Hide resolved
Qualified name is required to exclude functions. And computing the 
qualified name assumes that there is no functions at the root level. So 
we need to wrap root level functions before exclusion.
Copy link
Contributor

@lachrist lachrist left a comment

Choose a reason for hiding this comment

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

I still have an issue with your removal of the assertion. I made a fix in #185. You could leave the test but it will need to be updated because the qualified name of a root function is with the filename.

@dustinbyrne dustinbyrne force-pushed the fix/record-scanner branch 2 times, most recently from 15b57a2 to e03c634 Compare February 1, 2023 15:44
@dustinbyrne
Copy link
Contributor Author

I've rebased off the branch in #185 and dropped the commit to pass the assertion. The test seems unnecessary without providing an undefined or null parent.

Copy link
Contributor

@lachrist lachrist left a comment

Choose a reason for hiding this comment

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

Brazinga

@lachrist lachrist merged commit 9519e66 into main Feb 1, 2023
@appland-release
Copy link

🎉 This PR is included in version 13.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@appland/scanner can be recorded
3 participants