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

Internal error in @axiomhq/winston causing npx tsc to fail #180

Open
ayushyadav468 opened this issue May 12, 2024 · 2 comments
Open

Internal error in @axiomhq/winston causing npx tsc to fail #180

ayushyadav468 opened this issue May 12, 2024 · 2 comments

Comments

@ayushyadav468
Copy link

I am using @axiomhq/winston to integrate winston and axiom. But this fails to build(build script: npx tsc)

Error by tsc:
node_modules/@axiomhq/js/dist/esm/types/fetchClient.d.ts - error TS2314: Generic type 'RequestInitWithRetry' requires 1 type argument(s).

These lines:
doReq<T>(endpoint: string, method: string, init?: RequestInitWithRetry, searchParams?: {
post<T>(url: string, init?: RequestInitWithRetry, searchParams?: any): Promise<T>;
get<T>(url: string, init?: RequestInitWithRetry, searchParams?: any): Promise<T>;
put<T>(url: string, init?: RequestInitWithRetry, searchParams?: any): Promise<T>;
delete<T>(url: string, init?: RequestInitWithRetry, searchParams?: any): Promise<T>;

My logger file:

import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
import winston from 'winston';

const { combine, errors, json } = winston.format;
const NODE_ENV = process.env.NODE_ENV ?? 'development';
let logger: winston.Logger;
if (NODE_ENV === 'production') {
	// Create a new Axiom transport instance
	const axiomTransport = new AxiomTransport({
		dataset: process.env.AXIOM_DATASET ?? '',
		token: process.env.AXIOM_TOKEN ?? '',
		orgId: process.env.AXIOM_ORG_ID ?? ''
	});
	logger = winston.createLogger({
		level: 'http',
		format: combine(errors({ stack: true }), json()),
		transports: [axiomTransport],
		exceptionHandlers: [axiomTransport],
		rejectionHandlers: [axiomTransport]
	});
} else {
	logger = winston.createLogger({
		level: 'http',
		format: combine(errors({ stack: true }), json()),
		transports: [new winston.transports.Console()],
		exceptionHandlers: [new winston.transports.Console()],
		rejectionHandlers: [new winston.transports.Console()]
	});
}
// Wrapper for the logger
export const log = (level: string, message: string, meta?: any) => {
	return logger.log({
		level,
		message,
		meta
	});
};

node: 20.11.1
npm: 10.2.4
typescript: 5.2.2
@axiomhq/winston: 1.0.0-rc.3
@axiomhq/js: 1.0.0-rc.3

@schehata
Copy link
Collaborator

hi @ayushyadav468 thanks for brining this up, I've created a PR to test a change for fixing this. If all goes will, it will be part of the next release.

@schehata
Copy link
Collaborator

waiting for #189 to include these together in the next release.

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

No branches or pull requests

2 participants