js-sdk
js-sdk copied to clipboard
Warn on usage of older versions of the SDK
Describe the proposal
This is a derived issue from #260. It is to add a warning during startup if the user is on an older version of the Dapr SDK than the latest one. From #260,
Also add a message to runtime startup to check the latest version and to show when a new one is available (see Prisma for an example) https://registry.npmjs.org/@dapr/dapr
We must also consider the perf cost of a network call during startup.
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
@shubham1172 for these we have to compare SDK_VERSION from version .ts and current version from npm registry . to compare version we can use https://www.npmjs.com/package/semver . if you give some more idea i can do this @shubham1172
@salmankhan-prs yes, sounds like a plan.
@shubham1172 The function to fetch current version from npm registry where i have write in DaprClient.ts ??
@shubham1172 The function to fetch current version from npm registry where i have write in DaprClient.ts ??
When we move to multiple packages in v3.0.0, each package should contain it separately. For now, we can add it to DaprClient, similar to the dapr-client NPM package check IMO. The actual fetching of the version can be a utility in src/utils/Version.util.ts.
@XavierGeerinck WDYT?
@shubham1172 in DaprClient.ts should i need to create a new function .since i making network call to get the current version I am using await somethings like this
const latestVersion=await getLatestVersionFromNpmRegistry()
You can keep the logic under src/utils/Version.util.ts @salmankhan-prs
Hello, @shubham1172. Please review the version.utils.ts file I created below. Also, where should I call this function from?
import fetch from "node-fetch";
import { SDK_VERSION } from "../version";
import semver from 'semver'
import { Logger } from "../logger/Logger";
export const getLatestVersionFromNpmRegistry = async () => {
const logger = new Logger("DaprClient", "DaprClient", {});
const result = await fetch("https://registry.npmjs.org/@dapr/dapr");
const response = await (result.json());
const latestVersion= response["dist-tags"]["latest"];
if (semver.lt(String(SDK_VERSION), latestVersion) ) {
logger.warn(
`The ${latestVersion} version is available run npm update @dapr/dapr `,
);
}
};
@shubham1172 where should I call the above function ?
@salmankhan-prs see this, similar to the same check https://github.com/dapr/js-sdk/blob/f9571d5b34f5b1f41a06ba9b9b4da0c2c0f3fb36/src/implementation/Client/DaprClient.ts#L102-L106
@salmankhan-prs see this, similar to the same check
https://github.com/dapr/js-sdk/blob/f9571d5b34f5b1f41a06ba9b9b4da0c2c0f3fb36/src/implementation/Client/DaprClient.ts#L102-L106
yes @shubham1172 we are doing this inside constructor .I think we cannot call async function in the constructor
@salmankhan-prs see this, similar to the same check https://github.com/dapr/js-sdk/blob/f9571d5b34f5b1f41a06ba9b9b4da0c2c0f3fb36/src/implementation/Client/DaprClient.ts#L102-L106
yes @shubham1172 we are doing this inside constructor .I think we cannot call async function in the constructor .please correct me if i am wrong
After some more discussion, closing this issue as won't fix. The problem is that app environments might not always have internet access (airgap), or slow internet, and this functionality might cause more issues than good. Users should rather depend on npm to keep their dependencies up to date.