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

thrift-server: (extra-large) update dependencies, rename @creditkarma -> @statestitle #5

Merged
merged 7 commits into from
Jan 14, 2022

Conversation

strmer15
Copy link

All the dependency versions have been updated to their latest, some notable things:

  • typescript - set to ~4.4.4 since the 4.5.x line has some performance issues and breaks thrift code generation due to some changed APIs
    • This caused some build breakage with new Promise(...) needing to be changed to new Promise<void>(...) in a few places, as well as needing to do instanceof checks on caught errors since they're now typed as unknown by default
  • @types/node - set to ^12.20.41 to support Node 12 and up, since they're the current LTS versions
    • This caused some build breakage due to changes in some Buffer APIs that no longer allowed a boolean parameter for turning assertions on/off
  • tslint - set to the highest version available, but the entire tslint package is deprecated in favor of eslint and @typescript-eslint. This PR is big enough as it is without trying to also fix that.
    • Because of this and the prettier upgrade, there were a bunch of linting fixes in this PR
  • zipkin - this upgrade involved renaming parentId to parentSpanId, but also unwrapping some of the optional values using getOrElse

Also, all the @creditkarma instances have been renamed to @statestitle for consistency, and Github links were fixed to point at the StatesTitle repo.

  • Because of this, some tests broke because we're now using the @statestitle/typescript-thrift library, which means that exceptions can't use the message field without it being required. Also, some tests were expecting to get a specific message string, so the thrift files were updated to add the exception to the throws clause and set the message correctly in the server code.

All tests pass now, but to try this out you'll need to run npm run clean, npm install, then npm test.

@strmer15 strmer15 changed the title update dependencies, rename @creditkarma -> @statestitle (extra-large) update dependencies, rename @creditkarma -> @statestitle Jan 14, 2022
@strmer15 strmer15 requested review from a team January 14, 2022 17:29
@strmer15 strmer15 changed the title (extra-large) update dependencies, rename @creditkarma -> @statestitle thrift-server: (extra-large) update dependencies, rename @creditkarma -> @statestitle Jan 14, 2022
},
"devDependencies": {
"lerna": "^3.14.1"
"lerna": "^4.0.0"

Choose a reason for hiding this comment

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

I'm guessing no breaking changes we care about

Copy link
Author

Choose a reason for hiding this comment

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

Here's the changelog: https://github.com/lerna/lerna/blob/main/CHANGELOG.md

It didn't seem like anything that I was too worried about, a lot of exports but I don't think this code uses lerna programmatically, and the only other thing was dropping Node 6 and 8 support.

Copy link

@anandkumarpatel anandkumarpatel left a comment

Choose a reason for hiding this comment

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

tests passed for me!
there are some creditkarma things in README but they don't really matter:

$ git grep credit.*thrift-client
README.md:} from '@creditkaram/thrift-client'
README.md:} from '@creditkaram/thrift-client'
packages/thrift-client-zipkin-filter/README.md:} from '@creditkaram/thrift-client'

@strmer15
Copy link
Author

tests passed for me!

🎉

there are some creditkarma things in README but they don't really matter:

$ git grep credit.*thrift-client
README.md:} from '@creditkaram/thrift-client'
README.md:} from '@creditkaram/thrift-client'
packages/thrift-client-zipkin-filter/README.md:} from '@creditkaram/thrift-client'

ooh, thanks - I'll fix those, I think at first I was skipping the README files and then I went back to update them too, but obviously missed some.

@strmer15 strmer15 merged commit d23410e into main Jan 14, 2022
@strmer15 strmer15 deleted the cplummer/TPS-2572/updated_dependencies branch January 14, 2022 21:06
Copy link

@markdoliner-doma markdoliner-doma left a comment

Choose a reason for hiding this comment

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

Whew, thanks for making all these changes.

@@ -177,10 +177,14 @@ export class Connection {
}
}
} catch (err) {
let message = ''

Choose a reason for hiding this comment

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

I'm wondering if there's a better pattern we should use here. Like use "Unknown" if it's not an instanceof Error? Or err = message?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I'll make the default message be Unknown, seems like a decent idea.

code: { status: new thrift.Int64(0) },
value: 'test',
},
{ skip: ['_annotations', '_fieldAnnotations'] },

Choose a reason for hiding this comment

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

Why do we need to skip comparing these fields now? (in this file and in others in the PR)

Copy link
Author

Choose a reason for hiding this comment

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

There were some changes in the @hapi/code library (test matchers, https://github.com/hapijs/code) that seem to make this not work the way it was before - specifically object comparisons where one is missing keys that the other has. I think that it may have been caused by this change?

Anyways, the tests were failing because those two keys were present in the resulting object but not in the object here in the test. I couldn't figure out a better way to do this other than skipping the problematic properties (the includes function didn't seem to do it). In Jest I'd just use expect.objectContaining but I couldn't find similar functionality in @hapi/code.

@@ -47,7 +47,7 @@ function is128bit(traceId: TraceId): boolean {
export function serializeLinkerdHeader(traceId: TraceId): string {
const serialized: ByteBuffer = ByteBuffer.concat([
ByteBuffer.fromHex(traceId.spanId),
ByteBuffer.fromHex(traceId.parentId),
ByteBuffer.fromHex(traceId.parentSpanId.getOrElse('')),

Choose a reason for hiding this comment

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

I think I don't understand the getOrElse() API. It seems like it makes things hard to use. Can parentSpanId ever actually be unset? Is it really safe to use an empty string in those cases?

I'm obviously not familiar with any of the code in this file.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, the zipkin library updates (used for request tracing, it seems) changed the name but also wrapped these fields in some kind of Optional object where you have to call this method or something similar to unwrap the actual value (it's similar to other Java APIs I've seen in the past for wrapping possible null values). You can call getOrElse() without a default value and it would be string | undefined, but the fromHex function requires a string, so this seemed like the closest equivalent to how it would have been before? All the tests pass and this seems like the best equivalent - apparently parentSpanId can be unset (otherwise it wouldn't be this Optional type), and I believe an empty string is pretty safe to use (certainly more so than a null or undefined value).

I'm not crazy about the syntax either (obviously a ?? would seem a bit nicer than calling getOrElse) but I also don't know how to really get that changed other than switching it to a different library. 🤷

@strmer15
Copy link
Author

Whew, thanks for making all these changes.

Thanks for reviewing them!

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

Successfully merging this pull request may close these issues.

3 participants