rodrigo
rodrigo
Explore posts from servers
CDCloudflare Developers
Created by rodrigo on 1/7/2024 in #workers-help
Custom Markdoc's components work on local with wrangler but fail online with Pages
I've create a custom Markdoc components following this guide: https://markdoc.dev/docs/examples/react In local, the component (Counter) works ok, and when consologing you get this:
{
'$$mdtype': 'Tag',
name: 'Counter',
attributes: [Object],
children: []
}
{
'$$mdtype': 'Tag',
name: 'Counter',
attributes: [Object],
children: []
}
But on deploying to Pages I get an error
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
and the console:
{
'$$mdtype': 'Tag',
name: '_R',
attributes: [Object],
children: []
}
{
'$$mdtype': 'Tag',
name: '_R',
attributes: [Object],
children: []
}
So it's like the render is working locally and not online. I've spotted the 'rendering error' in the transform method:
const ast = parse(markdown)
const config = {
tags: { counter, },

}
return transform(ast, config)
const ast = parse(markdown)
const config = {
tags: { counter, },

}
return transform(ast, config)
` What else can I do to debug it? Is the bug in Worker backend?? (because Markdoc works ok locally)
2 replies
CDCloudflare Developers
Created by rodrigo on 10/2/2023 in #workers-help
Stripe with Remix 2.0
I'm using Stripe with Remix on CF Pages, using this configuration:
export const stripe = (stripe_key) =>
new Stripe(stripe_key, {
apiVersion: '2023-08-16',
typescript: true,
httpClient: Stripe.createFetchHttpClient(),
})
export const stripe = (stripe_key) =>
new Stripe(stripe_key, {
apiVersion: '2023-08-16',
typescript: true,
httpClient: Stripe.createFetchHttpClient(),
})
` I've tried many ways but I always get this error:
node_modules/object-inspect/util.inspect.js:1:25:
1 │ module.exports = require('util').inspect;
╵ ~~~~~~

The package "util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
node_modules/object-inspect/util.inspect.js:1:25:
1 │ module.exports = require('util').inspect;
╵ ~~~~~~

The package "util" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
Is this related with ESM config in Remix 2.0. ? I thught Stripe was totally compatible with Workers...
9 replies
CDCloudflare Developers
Created by rodrigo on 7/25/2023 in #general-help
Call Azure function from a Worker
I need to call an Azure function (to run an script on NodeJS) from a CF Worker (Remix on Cf Pages). Is it possible? How can I do that?
7 replies
CDCloudflare Developers
Created by rodrigo on 4/26/2023 in #pages-help
websocket abruptly closes
I'm using MS cognitive services with CloudFlare Pages and the websocket connection closes before covnerting text to audio and generting the file:
console.log(sdk.Diagnostics.SetLoggingLevel(sdk.LogLevel.Debug));

const prom = new Promise((resolve, reject) => {
const synthesizer = new sdk.SpeechSynthesizer(speechConfig, null);

synthesizer.speakSsmlAsync(
ssml,
async (result) => {
console.log('RESULT', result);
if (result.errorDetails) {
console.log('1 if ');
console.log('ERROR', result.errorDetails);
synthesizer.close();
} else {
console.log('2 if');
const file = new File([result.audioData], fileName, {
type: 'audio/mp3',
lastModified: Date.now()
});
const res = await context.env.R2_IGLSBKT.put(fileName, file);
console.log('res R2', res);
synthesizer.close();
resolve(fileName);
}
},
(error) => {
console.log('err', error);
synthesizer.close();
}
);
});

await context.waitUntil(prom);
console.log(sdk.Diagnostics.SetLoggingLevel(sdk.LogLevel.Debug));

const prom = new Promise((resolve, reject) => {
const synthesizer = new sdk.SpeechSynthesizer(speechConfig, null);

synthesizer.speakSsmlAsync(
ssml,
async (result) => {
console.log('RESULT', result);
if (result.errorDetails) {
console.log('1 if ');
console.log('ERROR', result.errorDetails);
synthesizer.close();
} else {
console.log('2 if');
const file = new File([result.audioData], fileName, {
type: 'audio/mp3',
lastModified: Date.now()
});
const res = await context.env.R2_IGLSBKT.put(fileName, file);
console.log('res R2', res);
synthesizer.close();
resolve(fileName);
}
},
(error) => {
console.log('err', error);
synthesizer.close();
}
);
});

await context.waitUntil(prom);
I got this error:
(log) ERROR websocket send error: Websocket not ready 7E9767F5499D4D44AB1AEADF2328152C DA30C36F329148D58231F50472556959 Error
at $e.sendRawMessage (functionsWorker-0.04974505925468953.js:33452:129)
at $e.<anonymous> (functionsWorker-0.04974505925468953.js:33474:22)
at Generator.next (<anonymous>)
at c (functionsWorker-0.04974505925468953.js:33336:13)
(log) ERROR websocket send error: Websocket not ready 7E9767F5499D4D44AB1AEADF2328152C DA30C36F329148D58231F50472556959 Error
at $e.sendRawMessage (functionsWorker-0.04974505925468953.js:33452:129)
at $e.<anonymous> (functionsWorker-0.04974505925468953.js:33474:22)
at Generator.next (<anonymous>)
at c (functionsWorker-0.04974505925468953.js:33336:13)
My understanding is that WaitUntil kept the task running in the background until completion. Why then does the ws end before completion? How can I keep running in the background? (I'm in Unbound mode)
13 replies
CDCloudflare Developers
Created by rodrigo on 3/16/2023 in #workers-help
Microsoft Cognitive Services
I've opened an issue with Microsoft to check if MS cognitive services SDK works with Workers. https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/645 They've fixed/remove code that was giving me the TypeError: globalThis.XMLHttpRequest is not a constructor error. But now it seems the sdk cannot connect to Azure's wss server. I'm not sure why but I've read here that wrangler doesn't work with wss but only with ws. Is that right?
2 replies
CDCloudflare Developers
Created by rodrigo on 2/8/2023 in #workers-help
Multiple reads with flareutils `list`
I'm trying to launch several flareutil list in parallel
await Promise.all(
arrPrefix.map(async (prefix) => {
const values = await serviceBKV.list({
prefix
});
await Promise.all(
arrPrefix.map(async (prefix) => {
const values = await serviceBKV.list({
prefix
});
I'm getting this error because I understand within list it's writing a Response: TypeError: Body has already been used. It can only be used once. Use tee() first if you need to read it twice What can I do to launch several list in parallel?
2 replies
CDCloudflare Developers
Created by rodrigo on 2/5/2023 in #pages-help
how to debug a function
I'm creating a webhook in Supabase to update a CF Worker KV. The point is that for every post request I can get the payload data but I cannot get any more info apart that post request is cancelled
"outcome": "canceled"
"outcome": "canceled"
I mean, I create conselo.log but this info doesn't show up in the request Real-time Logs. How can I get debug info in the log?
18 replies