Ping for toast
Ping for toast
Explore posts from servers
CDCloudflare Developers
Created by Ping for toast on 9/25/2024 in #workers-help
In CI, setting a newer wrangler target causes `npm i [email protected]` which causes error
No description
2 replies
SSolidJS
Created by Ping for toast on 8/9/2024 in #support
Infinite context loop in start dev?
Hi, I have
const [MeProvider, useMe] = createContextProvider(() => {
let [me, { mutate: setMe, refetch: refreshMe }] = createResource(async () => {
// this runs forever
console.log("running!")
return (await client.user.me.get()).data;
});
return {
me,
setMe,
refreshMe,
};
});
const [MeProvider, useMe] = createContextProvider(() => {
let [me, { mutate: setMe, refetch: refreshMe }] = createResource(async () => {
// this runs forever
console.log("running!")
return (await client.user.me.get()).data;
});
return {
me,
setMe,
refreshMe,
};
});
, and I'm noticing that this createResource is running forever as fast as possible, on the server, when its in dev. I'm trying to discover the root cause of it, but it only happens in dev. I'm posting this half for help, and half to help others when I uncover the issue
15 replies
CDCloudflare Developers
Created by Ping for toast on 5/23/2024 in #workers-help
[VERY EXTREMELY CURSED] How can I access process.env (at start time)
Ahoy! I need .env to instantiate my jwt server. I've spent so much time of my life reading minified code and dealing with build tools, BUT I HAVE NO IDEA WHATS GOING ON!!! Solid start somehow uses vite, rollup, esbuild, vinxi, and nitro. and then I suppose cf is doing its own polyfills Has javascript gone too far???? But anyway My first attempt is
export const authPlugin = new Elysia({ name: "authPlugin" }).use(
jwt({
secret: process.env.JWT_SECRET!,
// ...
})
);
export const authPlugin = new Elysia({ name: "authPlugin" }).use(
jwt({
secret: process.env.JWT_SECRET!,
// ...
})
);
but this didn't work, process.env is undefined despite node.js compat being enabled. Looking inside the bundled code, I see .use(jwt({secret:J.env.JWT_SECRET, what is J? const J=H.process. Ok lets zoom out
N.title="unenv";const U=Object.create(null),W=globalThis.process?.env,_getEnv=s=>W||globalThis.__env__||(s?U:globalThis);function noop$1(){return N}N.env=new Proxy(U,{get:(s,c)=>_getEnv()[c]??U[c],has:(s,c)=>c in _getEnv()||c in U,set:(s,c,u)=>(_getEnv(!0)[c]=u,!0),deleteProperty(s,c){delete _getEnv(!0)[c]},ownKeys(){const s=_getEnv();return Object.keys(s)}}),N.argv=[],N.version="",N.versions={},N.on=noop$1,N.addListener=noop$1,N.once=noop$1,N.off=noop$1,N.removeListener=noop$1,N.removeAllListeners=noop$1,N.emit=noop$1,N.prependListener=noop$1,N.prependOnceListener=noop$1,N.listeners=function(s){return[]},N.binding=function(s){throw new Error("[unenv] process.binding is not supported")};let V="/";N.cwd=function(){return V},N.chdir=function(s){V=s},N.umask=function(){return 0};const H="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};H.process=H.process||N;const J=H.process
N.title="unenv";const U=Object.create(null),W=globalThis.process?.env,_getEnv=s=>W||globalThis.__env__||(s?U:globalThis);function noop$1(){return N}N.env=new Proxy(U,{get:(s,c)=>_getEnv()[c]??U[c],has:(s,c)=>c in _getEnv()||c in U,set:(s,c,u)=>(_getEnv(!0)[c]=u,!0),deleteProperty(s,c){delete _getEnv(!0)[c]},ownKeys(){const s=_getEnv();return Object.keys(s)}}),N.argv=[],N.version="",N.versions={},N.on=noop$1,N.addListener=noop$1,N.once=noop$1,N.off=noop$1,N.removeListener=noop$1,N.removeAllListeners=noop$1,N.emit=noop$1,N.prependListener=noop$1,N.prependOnceListener=noop$1,N.listeners=function(s){return[]},N.binding=function(s){throw new Error("[unenv] process.binding is not supported")};let V="/";N.cwd=function(){return V},N.chdir=function(s){V=s},N.umask=function(){return 0};const H="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};H.process=H.process||N;const J=H.process
ok so nitro is being "helpful" and injecting unenv into the game. Ok so its looking at globalThis. Whats in globalThis? console.log(globalThis) OH LAWDY WHAT IS THIS (hahah globalThis get it puns?) 1/?
79 replies
RRailway
Created by Ping for toast on 5/5/2024 in #✋|help
Temporary failure in name resolution
No description
79 replies
RRailway
Created by Ping for toast on 5/1/2024 in #✋|help
Deployments aren't doing nothing
No description
133 replies
RRailway
Created by Ping for toast on 2/16/2024 in #✋|help
Secret Changing
@Brody asked me to open this. I was having issues with my secret changing every deploy. I think the cause of this was I did the secret inside an already existing project, not a template. But having the secret changing every deploy in every case is not fun.
10 replies
SSolidJS
Created by Ping for toast on 1/8/2023 in #support
Await Resource
I have an authentication context wrapping the router
export const [SessionProvider, useSession] = createContextProvider(() => {
const cookie = isServer
? useRequest().request.headers.get("cookie") ?? ""
: document.cookie
const [userSession] = createResource(async () => {
const session = await storage.getSession(cookie)
return {
instance: session.get('instance') as string || null,
key: session.get('key') as string || null
}
}, {
deferStream: true
})
return userSession
})
export const [SessionProvider, useSession] = createContextProvider(() => {
const cookie = isServer
? useRequest().request.headers.get("cookie") ?? ""
: document.cookie
const [userSession] = createResource(async () => {
const session = await storage.getSession(cookie)
return {
instance: session.get('instance') as string || null,
key: session.get('key') as string || null
}
}, {
deferStream: true
})
return userSession
})
And later use the session context in certain functions
const gclc = () => createClient({
url: `https://${useSession()().instance}/api/graphql`,
fetchOptions: () => {
return {
headers: {
'Authorization': `Bearer ${useSession()().key}`
}
}
}
})
const gclc = () => createClient({
url: `https://${useSession()().instance}/api/graphql`,
fetchOptions: () => {
return {
headers: {
'Authorization': `Bearer ${useSession()().key}`
}
}
}
})
But it appears that in some contexts, useSession is still unloaded when it is called. I need some way to await the resource ready state if it isn't ready already, or some better way to do this
2 replies