Skip to content

Commit

Permalink
fix: start als on main method
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmpinto committed Oct 22, 2024
1 parent c8faf01 commit 7c10f37
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 78 deletions.
114 changes: 94 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/next-on-fleek/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleek-platform/next-on-fleek",
"version": "1.14.6",
"version": "1.14.7",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/src/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions packages/next-on-fleek/src/api/getRequestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type RequestContext<
ctx: Context;
};

const cloudflareRequestContextSymbol = Symbol.for(
'__cloudflare-request-context__',
const fleekRequestContextSymbol = Symbol.for(
'__fleek-request-context__',
);

export function getOptionalRequestContext<
Expand All @@ -24,11 +24,11 @@ export function getOptionalRequestContext<
>(): undefined | RequestContext<CfProperties, Context> {
const cloudflareRequestContext = (
globalThis as unknown as {
[cloudflareRequestContextSymbol]:
[fleekRequestContextSymbol]:
| RequestContext<CfProperties, Context>
| undefined;
}
)[cloudflareRequestContextSymbol];
)[fleekRequestContextSymbol];

if (inferRuntime() === 'nodejs') {
// no matter what, we want to throw if either
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export async function buildWorkerFile(
minify,
}: BuildWorkerFileOpts,
): Promise<string> {
// eslint-disable-next-line no-console
console.log('Building worker file');

const functionsFile = join(
tmpdir(),
`functions-${Math.random().toString(36).slice(2)}.js`,
Expand Down
33 changes: 0 additions & 33 deletions packages/next-on-fleek/src/buildApplication/generateGlobalJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,38 +128,5 @@ export function generateGlobalJs(): string {
globalThis.Buffer = Buffer;
})
.catch(() => null);
const __ALSes_PROMISE__ = import('node:async_hooks').then(({ AsyncLocalStorage }) => {
globalThis.AsyncLocalStorage = AsyncLocalStorage;
const envAsyncLocalStorage = new AsyncLocalStorage();
const requestContextAsyncLocalStorage = new AsyncLocalStorage();
globalThis.process = {
env: new Proxy(
{},
{
ownKeys: () => Reflect.ownKeys(envAsyncLocalStorage.getStore()),
getOwnPropertyDescriptor: (_, ...args) =>
Reflect.getOwnPropertyDescriptor(envAsyncLocalStorage.getStore(), ...args),
get: (_, property) => Reflect.get(envAsyncLocalStorage.getStore(), property),
set: (_, property, value) => Reflect.set(envAsyncLocalStorage.getStore(), property, value),
}),
};
globalThis[Symbol.for('__cloudflare-request-context__')] = new Proxy(
{},
{
ownKeys: () => Reflect.ownKeys(requestContextAsyncLocalStorage.getStore()),
getOwnPropertyDescriptor: (_, ...args) =>
Reflect.getOwnPropertyDescriptor(requestContextAsyncLocalStorage.getStore(), ...args),
get: (_, property) => Reflect.get(requestContextAsyncLocalStorage.getStore(), property),
set: (_, property, value) => Reflect.set(requestContextAsyncLocalStorage.getStore(), property, value),
}
);
return { envAsyncLocalStorage, requestContextAsyncLocalStorage };
})
.catch(() => null);
`;
}
Loading

0 comments on commit 7c10f37

Please sign in to comment.