Skip to main content

Posts

Showing posts from September, 2024

Solving Expo Notification Issues on Preview Build: The Project ID Fix

When building mobile applications, notifications are a crucial feature, helping to keep users engaged and updated. If you’re using Expo and a NestJS backend to handle push notifications, you might have noticed a strange quirk: notifications work perfectly fine in development but mysteriously fail in preview builds . That was exactly the issue I faced while working on my app. Everything was going smoothly during development, but once I moved to preview builds, the push notifications simply wouldn’t come through. After spending hours troubleshooting, I finally figured out the problem —  the Project ID . This article will walk you through the issue and provide the solution I found, saving you hours of head-scratching. The Problem: Notifications Work in Development, But Not in Preview While setting up push notifications using Expo, I used the following code to retrieve the Expo push token: expoPushToken = (await Notifications.getExpoPushTokenAsync()).data ; This code worked perfect...

Resolving the “Javascript Heap Out of Memory” Error While Building React Native Apps Locally with EAS

  Introduction When building a React Native app, you may encounter various challenges, especially when dealing with memory issues during the build process. One of the more frustrating errors is the “Javascript heap out of memory” error. Recently, I encountered this issue while building my React Native app locally using Expo Application Services (EAS) . It was a blocker that halted my progress, and after some research, I found a solution that I’d like to share. This blog will walk you through the error I faced, the steps I took to resolve it, and how you can apply these solutions to your own project. If you’re working with EAS or React Native, this guide should help you optimize your build process and avoid memory-related errors. The Problem: “Javascript Heap Out of Memory” Error Here’s what happened when I attempted to build my app locally using EAS Build : FAILURE: Build failed with an exception. Javascript heap out of memory. The error typically happens when Node.js runs ...

How to Overcome the Challenges of Building an Electron App for Windows on a Mac

Building cross-platform applications with Electron is one of the framework’s key strengths. However, the process isn’t always seamless, especially when trying to build a Windows app on a macOS machine. While macOS can handle its own builds flawlessly, the journey to create a Windows-compatible app often involves unexpected obstacles. After personally navigating this challenge, I’ve compiled insights and practical steps to help others avoid the pitfalls I encountered. The Problem When I built my Electron app for macOS, everything worked perfectly. The app compiled without issues, and testing went smoothly. Feeling confident, I attempted to build the Windows version of the same app from my MacBook. That’s when the problems began. Despite using the same codebase, the build process for Windows became a frustrating exercise in troubleshooting. Among the many issues I faced, one of the most persistent errors was: Error: spawn EINVAL at ChildProcess.spawn, errno: -4071 This error occurr...

How to Fix “FATAL ERROR: Reached heap limit Allocation failed — JavaScript heap out of memory” in Nest.js on Google Cloud Run

  When deploying a Nest.js application to Google Cloud Run, you might encounter the following error: FATAL ERROR: Reached heap limit Allocation failed — JavaScript heap out of memory This error usually occurs when the Node.js process runs out of memory, leading to a crash. It can be surprising, especially if your application is relatively small, as was the case with my project, which is just a simple web backend. The Problem During deployment, I was surprised to encounter this heap memory issue because my Nest.js application wasn’t particularly large or resource-intensive. Initially, my app was allocated 512MB of memory, which seemed sufficient given its simplicity. However, during the deployment on Google Cloud Run, the application crashed with the above error message. Quick Fix Given that I was pressed for time to finish the project, I opted for a quick solution: - Increased Memory Allocation: I increased the memory allocation for my Cloud Run service from 512MB to 4GB. This imm...