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

Remove verbose event keys warning #382

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-ghosts-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Remove verbose event keys warning
40 changes: 0 additions & 40 deletions packages/inngest/src/components/Inngest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,6 @@ const testEvent: EventPayload = {

const testEventKey = "foo-bar-baz-test";

describe("instantiation", () => {
describe("event key warnings", () => {
let warnSpy: jest.SpyInstance;
const originalEnvEventKey = process.env[envKeys.InngestEventKey];

beforeEach(() => {
warnSpy = jest.spyOn(console, "warn");
});

afterEach(() => {
warnSpy.mockReset();
warnSpy.mockRestore();

if (originalEnvEventKey) {
process.env[envKeys.InngestEventKey] = originalEnvEventKey;
} else {
delete process.env[envKeys.InngestEventKey];
}
});

test("should log a warning if event key not specified", () => {
createClient({ id: "test" });
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining("Could not find event key")
);
});

test("should not log a warning if event key is specified", () => {
createClient({ id: "test", eventKey: testEventKey });
expect(warnSpy).not.toHaveBeenCalled();
});

test("should not log a warning if event key is specified in env", () => {
process.env[envKeys.InngestEventKey] = testEventKey;
createClient({ id: "test" });
expect(warnSpy).not.toHaveBeenCalled();
});
});
});

describe("send", () => {
describe("runtime", () => {
const originalProcessEnv = process.env;
Expand Down
15 changes: 0 additions & 15 deletions packages/inngest/src/components/Inngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,6 @@ export class Inngest<TOpts extends ClientOptions = ClientOptions> {

this.setEventKey(eventKey || processEnv(envKeys.InngestEventKey) || "");

if (!this.eventKeySet()) {
console.warn(
prettyError({
type: "warn",
whatHappened: "Could not find event key",
consequences:
"Sending events will throw in production unless an event key is added.",
toFixNow: fixEventKeyMissingSteps,
why: "We couldn't find an event key to use to send events to Inngest.",
otherwise:
"Create a new production event key at https://app.inngest.com/env/production/manage/keys.",
})
);
}

this.headers = inngestHeaders({
inngestEnv: env,
});
Expand Down